[colug-432] Bourne v Bash Subtlety: Ubuntu v Centos: Burned Again
jep200404 at columbus.rr.com
jep200404 at columbus.rr.com
Thu Jan 14 14:29:06 EST 2016
On Tue, 12 Jan 2016 13:52:13 -0500, jep200404 at columbus.rr.com wrote:
> I was burned by a subtle difference between Bourne shell and bash.
>
> lunch at phyphompho:~/20160113$ ./p1.sh hello world
> p3 $1: hello
> p3 $@: hello world
> p3 $1: hello
> p3 $@: hello world
> lunch at phyphompho:~/20160113$ ./p2.sh hello world
> p3 $1: hello
> p3 $@: hello world
> p3 $1: moby
> p3 $@: moby grape
> lunch at phyphompho:~/20160113$ ll p*
That was on Ubuntu 14.04.3
Centos 7 yields different results:
[lunch at cohpy 20160120]$ ./p1.sh hello world
p3 $1: hello
p3 $@: hello world
p3 $1: moby
p3 $@: moby grape
[lunch at cohpy 20160120]$ ./p2.sh hello world
p3 $1: hello
p3 $@: hello world
p3 $1: moby
p3 $@: moby grape
[lunch at cohpy 20160120]$ ll p*
-rwxr-x---. 1 lunch lunch 42 Jan 14 14:05 p1.sh
-rwxr-x---. 1 lunch lunch 44 Jan 14 14:05 p2.sh
-rw-r-----. 1 lunch lunch 36 Jan 14 14:05 p3.sh
[lunch at cohpy 20160120]$ head p*
==> p1.sh <==
#!/bin/sh
. ./p3.sh
. ./p3.sh moby grape
==> p2.sh <==
#!/bin/bash
. ./p3.sh
. ./p3.sh moby grape
==> p3.sh <==
echo "p3 \$1: $1"
echo "p3 \$@: $@"
[lunch at cohpy 20160120]$ diff p1.sh p2.sh
1c1
< #!/bin/sh
---
> #!/bin/bash
[lunch at cohpy 20160120]$
More information about the colug-432
mailing list