difference between sh and bash

difference between sh and bash

am 07.10.2005 10:55:26 von Petterson Mikael

Hi,

When executing a shell script on solaris (/bin/sh) the following line
works fine:

eval `$mozilla_home/bin/mozilla -remote \'ping()\' < /dev/null`

but when run on linux (/bin/bash) I get the following error:

line 482: unexpected EOF while looking for matching ``'

Any one know I can make the following line execute in both sh and bash?

cheers,

//mikael

Re: difference between sh and bash

am 07.10.2005 11:39:42 von Jan Schampera

On Fri, 07 Oct 2005 10:55:26 +0200
Petterson Mikael wrote:

> When executing a shell script on solaris (/bin/sh) the following line
> works fine:
>
> eval `$mozilla_home/bin/mozilla -remote \'ping()\' < /dev/null`
[Sol /bin/sh vs Linux /bin/bash]

This line is syntactically more or less correct.
But I doubt it does what you think it does (why do you pump a EOF to
mozilla?).

Don't you just want
$mozilla_home/bin/mozilla -remote 'ping()' >/dev/null 2>&1
and fetch the exit code?
(didn't test it, but should be Solaris-proof)

For the error message: are you really sure you don't have a copy&paste
error (missing ``')? The line produces no error related to parsing here
on my box.

Jan

--
"Be liberal in what you accept, and conservative in what you send."
- J. B. Postel, master of the net.

Re: difference between sh and bash

am 07.10.2005 17:35:04 von Enrique Perez-Terron

On Fri, 07 Oct 2005 10:55:26 +0200, Petterson Mikael wrote:

> Hi,
>
> When executing a shell script on solaris (/bin/sh) the following line
> works fine:
>
> eval `$mozilla_home/bin/mozilla -remote \'ping()\' < /dev/null`
>
> but when run on linux (/bin/bash) I get the following error:
>
> line 482: unexpected EOF while looking for matching ``'
>
> Any one know I can make the following line execute in both sh and bash?

What does

$mozilla_home/bin/mozilla -remote \'ping()\' < /dev/null

return? When I try this on my Fedora Core 4, bash 3.00.16(1)-release,
I get:

bash: command substitution: line 1: syntax error near unexpected token `('

-Enrique

Re: difference between sh and bash

am 19.10.2005 22:31:06 von Sven Mascheck

Petterson Mikael wrote:

> When executing a shell script on solaris (/bin/sh) the following line
> works fine:
>
> eval `$mozilla_home/bin/mozilla -remote \'ping()\' < /dev/null`
>
> but when run on linux (/bin/bash) I get the following error:
>
> line 482: unexpected EOF while looking for matching ``'

Obviously you're running a long script and not just this line;
bash might stumble elsewhere over sloppy quoting: Traditional
bourne shells silently insert an unbalanced single, double or
back quote at EOF (including here-documents).

BTW, they are not alone: ksh88/93 accepts expressions like

$ echo "`pwd"

and even bash is more tolerant in here-docs,

$ cat< `echo ok
EOF
--