bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash vs sh / ticks appearing


From: Andreas Schwab
Subject: Re: bash vs sh / ticks appearing
Date: Sat, 29 Dec 2007 15:16:58 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

"Tuc at T-B-O-H.NET" <ml@t-b-o-h.net> writes:

>       When I brought it over to Linux using bash its doing
> some strange stuff...
>
> SCRIPT:
>
> #!/bin/sh -x
>
> SCRIPT=$1
> shift
> EMAIL=$1
>
> echo $SCRIPT
> $SCRIPT 1>/tmp/mailifoutput.$$ 2>&1

If you want the shell to reinterpret meta characters like quotes as part
of a parameter expansion, you need to use eval.

> sh/FreeBSD output:
>
> # ./script.sh "/usr/local/bin/otherprogram \"Param 1\" \"Param2\"" email
> + SCRIPT=/usr/local/bin/otherprogram "Param 1" "Param2"
> + shift
> + EMAIL=email
> + echo /usr/local/bin/otherprogram "Param 1" "Param2"
> /usr/local/bin/otherprogram "Param 1" "Param2"
> + /usr/local/bin/otherprogram "Param 1" "Param2"

The FreeBSD shell apparently displays the trace ambigously.

> bash 3.00.15(1)-release/Centos Linux 2.6.9-42.0.10.EL
> [root@sonar tmp]# ./script.sh "/usr/local/bin/otherprogram \"Param 1\" 
> \"Param2\"" email
> + SCRIPT='/usr/local/bin/otherprogram "Param 1" "Param2"'
> + shift
> + EMAIL=email
> + echo /usr/local/bin/otherprogram '"Param' '1"' '"Param2"'
> /usr/local/bin/otherprogram "Param 1" "Param2"
> + /usr/local/bin/otherprogram '"Param' '1"' '"Param2"'

>       Why does it insert the ticks,

They are single quotes and show you unambiguously the command that is
being exected.  You can copy the line minus the leading + into the shell
command line and get exactly the same command executed.

> which end up making /usr/local/bin/otherprogram fail?

If the FreeBSD shell does not execute the script the same way as Bash
then it has a serious bug.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]