Re: something strange with rsh/ssh + bash/tcsh is happening. Please advise
Scripsit Yaroslav Halchenko <debian@onerussian.com>
> -c string If the -c option is present, then commands are read
> from string. If there are arguments after the
> string, they are assigned to the positional
> parameters, starting with $0.
> so - sldkjf (if I read English correctly) should be assigned to $0
> (yikes again). Lets try:
>> cat zzz.sh
> #!/bin/bash
> echo "#0=$0 #1=$1"
> *> /bin/bash -c /home/yoh/zzz.sh sldkjf sdf sdf
> #0=/home/yoh/zzz.sh #1=
> so what the hell is right in this situation????
Bash behaves as the manual page says. The string is
'/home/yoh/zzz.sh', and every $1 in that string did indeed get
expanded to sdf, after which the command reads '/home/yoh/zzz.sh'.
On the other hand:
$ bash -c 'echo 0=$0 1=$1' sldkjf sdf sdf
0=sldkjf 1=sdf
$ bash -c 'source zzz.sh' sldkjf sdf sdf
#0=sldkjf #1=sdf
$
The argument to the -c option is being interpreted as _a shell script_
itself.
--
Henning Makholm "It will be useful even at this
early stage to review briefly the main
features of the universe as they are known today."
Reply to: