| www.delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com> |
| List-Archive: | <http://sourceware.cygnus.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT sourceware DOT cygnus DOT com> |
| List-Help: | <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, |
| <http://sourceware.cygnus.com/ml/#faqs> | |
| Sender: | cygwin-owner AT sourceware DOT cygnus DOT com |
| Delivered-To: | mailing list cygwin AT sourceware DOT cygnus DOT com |
| Message-ID: | <37C3CDD2.F8BD4C58@dev.tivoli.com> |
| Date: | Wed, 25 Aug 1999 13:04:50 +0200 |
| From: | Rob Tulloh <rob_tulloh AT dev DOT tivoli DOT com> |
| X-Mailer: | Mozilla 4.61 [en] (WinNT; U) |
| X-Accept-Language: | en |
| MIME-Version: | 1.0 |
| To: | cygwin AT sourceware DOT cygnus DOT com |
| Subject: | B20.1 sh and bash command line parsing question |
Hello,
As a maintainer of GNU make on WIN32 platforms, I am constantly asked
why Cygwin sh.exe and/or bash.exe don't work correctly when called
from make. I have a hack that forces all shell commands to be written
to a temp file and then run via 'sh file'. However, I don't like
this as it represents a unnecessary performance hit to make on WIN32
platforms. I have a simple test case that shows the problems.
I am trying to work out why sh.exe and bash.exe are not able to
be succesfully invoked via 'sh -c' from CreateProcess() for
all cases of command line. I have
a simple test example that can be run from the NT command prompt
which demonstrates the problem. There are 6 lines below which
use 3 shells to execute 2 different command lines:
> i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/sh.exe -c "if [ -d \"c:/temp\" ] ; then echo \"hi\" ; fi"
> i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/bash.exe -c "if [ -d \"c:/temp\" ] ; then echo \"hi\" ; fi"
> i:/tools/gk/bin/sh.exe -c "if [ -d \"c:/temp\" ] ; then echo \"hi\" ; fi"
> i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/sh.exe -c "if [ -d \"c:/temp\" ] ; then echo \"hi there\" ; fi"
> i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/bash.exe -c "if [ -d \"c:/temp\" ] ; then echo \"hi there\" ; fi"
> i:/tools/gk/bin/sh.exe -c "if [ -d \"c:/temp\" ] ; then echo \"hi there\" ; fi"
The first 2 shells are the ones from the Cygwin B20.1 distribution. The
3rd shell is Tivoli's custom port of GNU bash to Windows NT.
> I:\apps\work\cygnus\cygwin-b20>c:\temp\sp2.bat
>
> I:\apps\work\cygnus\cygwin-b20>i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/sh.exe
> -c "if [ -d \"c:/temp\" ] ; then echo \"hi\" ; fi"
> hi
>
> I:\apps\work\cygnus\cygwin-b20>i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/bash.ex
> e -c "if [ -d \"c:/temp\" ] ; then echo \"hi\" ; fi"
> hi
>
> I:\apps\work\cygnus\cygwin-b20>i:/tools/gk/bin/sh.exe -c "if [ -d \"c:/temp\" ]
> ; then echo \"hi\" ; fi"
> hi
>
> I:\apps\work\cygnus\cygwin-b20>i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/sh.exe
> -c "if [ -d \"c:/temp\" ] ; then echo \"hi there\" ; fi"
> Syntax error: Unterminated quoted string
>
> I:\apps\work\cygnus\cygwin-b20>i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/bash.ex
> e -c "if [ -d \"c:/temp\" ] ; then echo \"hi there\" ; fi"
> there\ ; fi: -c: line 1: unexpected EOF while looking for matching `"'
> there\ ; fi: -c: line 2: syntax error: unexpected end of file
>
> I:\apps\work\cygnus\cygwin-b20>i:/tools/gk/bin/sh.exe -c "if [ -d \"c:/temp\" ]
> ; then echo \"hi there\" ; fi"
> hi there
Notice how as soon as white space ("hi there") is introduced into a
string
embedded in the command line that
the parser breaks down and fails to parse the string correctly. I would
have thought that the parsing rules would follow the Microsoft C runtime
rules for argument parsing since it should be possible to invoke Cygwin
commands from CreateProcess() (natively from Win32) rather than having
to rely on fork/exec/whatever in cygwin.dll.
Note that I have made the parsing logic within make work for Tivoli's
custom
port of bash and also for the MKS version of sh. I am not able to figure
out what magic is needed to make this work with Cygwin sh or bash. I am
looking
for insight on what the parsing algorithm is and how to invoke commands
from
WIN32 so that sh/bash can parse them as I would expect.
Comments?
Thank you,
Rob Tulloh
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |