This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: long command executed via a variable fails
- From: Reini Urban <rurban at x-ray dot at>
- To: Geoffrey KRETZ <gk at 4js dot com>
- Cc: cygwin at cygwin dot com
- Date: Wed, 17 Nov 2004 17:04:46 +0100
- Subject: Re: long command executed via a variable fails
- References: <419B70A9.6020203@4js.com>
Geoffrey KRETZ schrieb:
I've got a problem with a shell script used with Cygwin 1.5.10-3 on
W2000 SP4 and W XP SP 2.
The following part of code works on all the Unix I've tested
(HP-UX/AIX/Sun Solaris/Linux).
With Cygwin, it doesn't :(
*Code:*
cmd="long shell command with differents parameters"
if [ ! eval $cmd ]; then
echo "Error : $cmd"
exit 1
fi
instead of eval $cmd, i've tried :
- `eval $cmd`
- eval `$cmd`
- $cmd
- `$cmd`
I've also try with a function without more success.
*Code:*
execCmd()
{
eval $cmd
return $?
}
cmd="long shell command with differents parameters"
if [ ! execCmd ]; then
echo "Error : $cmd"
exit 1
fi
The only way I've find is :
*Code:*
cmd="long shell command with differents parameters"
eval $cmd
if [ $? -ne 0 ]; then
echo "Error : $cmd"
exit 1
fi
Is it possible to make it work like the two first exemple or I'm obliged
to use the third solution ?
FAQ: http://cygwin.com/faq/faq_3.html#SEC43
cygwin's /bin/sh is ash, on most other platforms it is /bin/bash.
If you want it to behave it exactly like on other platforms, and you use
bash specific constructs, use the /bin/bash shebang.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
--
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/