Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Christopher Cobb Subject: Re: Problem executing a .bat script in a directory with spaces using bash Date: Tue, 7 Sep 2004 14:53:07 +0000 (UTC) Lines: 30 Message-ID: References: <5c8adab704090207557a3a359a AT mail DOT gmail DOT com> <4137566C DOT 7070203 AT sbcglobal DOT net> <5c8adab704090210405ea696e4 AT mail DOT gmail DOT com> <413760BD DOT 2080504 AT sbcglobal DOT net> <5c8adab70409021123291886c7 AT mail DOT gmail DOT com> <41376CD2 DOT 9090102 AT comcast DOT net> <41376D75 DOT 1060806 AT comcast DOT net> <4139AF96 DOT 4274702 AT dessent DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 162.70.244.40 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.8) X-IsSubscribed: yes Brian Dessent dessent.net> writes: > > Interesting function. However, I found that it chokes if the name of > the command to run has spaces, even if they are properly quoted on the > command line, e.g. > That's interesting. I'm running Win XP and even with your patches I /still/ get an error when a batch file path with spaces is given. Shell quoting hell + cmd.exe quoting hell is enough fun for a whole week! As if that's not enough, I see that (at least on XP) cmd.exe has a /S option to process quotes the "old way": "Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character." The "new way" is to preserve (exactly two) quotes in the command string if /all/ of the following five conditions are met: "(1) no /S switch; (2) exactly two quote characters; (3) no special characters between the two quote characters, where special is one of: &<>()@^|; (4) there are one or more whitespace characters between the the two quote characters; (5) the string between the two quote characters is the name of an executable file." I really like it that there /cannot/ be special characters between the quotes, and that there /must/ be whitespace characters between the quotes. (NOT!) I wonder if "executable file" includes batch files? I'll plug away at this some more and see if I can figure something out. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/