[colug-432] Bourne v Bash Subtlety: Ubuntu v Centos: Burned Again

Matthew Hyclak hyclak at gmail.com
Thu Jan 14 14:46:28 EST 2016


[mhyclak at centos-dev ~]$ lsb_release -d
Description: CentOS Linux release 7.2.1511 (Core)
[mhyclak at centos-dev ~]$ ls -l /bin/sh
lrwxrwxrwx. 1 root root 4 Dec 23 09:06 /bin/sh -> bash

Probably explains CentOS.

There is no sh, only Zuul

On Thu, Jan 14, 2016 at 2:29 PM, <jep200404 at columbus.rr.com> wrote:

> 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]$
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20160114/2197fb6b/attachment.html 


More information about the colug-432 mailing list