Prev: How to make a recording from a digital source (fiber) using an Intel 2007 MacBook Pro?
Next: How to make a recording from a digital source (fiber) using anIntel 2007 MacBook Pro?
From: Jolly Roger on 26 May 2010 15:27 In article <2010052612181975249-not(a)dotcom>, thepixelfreak <not(a)dot.com> wrote: > On 2010-05-25 18:37:22 -0700, Jolly Roger <jollyroger(a)pobox.com> said: > > > In article <2010052510030316807-not(a)dotcom>, > > thepixelfreak <not(a)dot.com> wrote: > > > >> I've noticed some differences in /bin/sh and /bin/bash shell script > >> execution. I'm wondering if anyone knows the differences between what > >> should be the same gnu bash interpreter? I have a script that changes > >> the color of text in Terminal.app. The script works (well, the ANSI > >> escape sequences work) with /bin/sh but fail with /bin/bash (they are > >> the VERY SAME version of bash). e.g. > > > > Bash is a superset of sh. > > Really? > > sh-3.2# /bin/sh --version > GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > > sh-3.2# /bin/bash --version > GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Yes, really: <http://www.faqs.org/docs/bashman/bashref_122.html> <http://en.wikipedia.org/wiki/Bourne_shell> <http://en.wikipedia.org/wiki/Bash> -- Send responses to the relevant news group rather than email to me. E-mail sent to this address may be devoured by my very hungry SPAM filter. Due to Google's refusal to prevent spammers from posting messages through their servers, I often ignore posts from Google Groups. Use a real news client if you want me to see your posts. JR
From: Jim Gibson on 26 May 2010 15:48 In article <2010052612175316807-not(a)dotcom>, thepixelfreak <not(a)dot.com> wrote: > >> Any idea what's going on here? > > > > Not really, except that echo is a built-in command, depends on the > > shell of which it is a part, and bash and sh are different. > > they clearly behave differently, but GNU would have you think they are > the very same binary. > > sh-3.2# /bin/sh --version > GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > > sh-3.2# /bin/bash --version > GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) They would be the same binary if both /bin/sh and /bin/bash pointed to the same file, or separate files that were exact copies of each other. They are not, so it is not exactly accurate to call them the "same binary". What it looks like is that both are based on the same source release, and sh is actually a version of bash, but with its behavior modified to match the historical behavior of sh. You can specify the shell to use in the first line (you probably know that already.) You can find out which shell is running with the $0 variable. That will allow you to use the correct version of shell built-ins where they differ, but that is a royal pain. Sorry, can't help any more than that. -- Jim Gibson
From: thepixelfreak on 26 May 2010 16:34 On 2010-05-26 12:27:13 -0700, Jolly Roger <jollyroger(a)pobox.com> said: >>> >>> Bash is a superset of sh. >> >> Really? >> >> sh-3.2# /bin/sh --version >> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) >> >> sh-3.2# /bin/bash --version >> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > > Yes, really: > > <http://www.faqs.org/docs/bashman/bashref_122.html> > > <http://en.wikipedia.org/wiki/Bourne_shell> > > <http://en.wikipedia.org/wiki/Bash> I'm very well aware that bash is a superset of bourne shell. My gripe is that the binaries provided by Apple both show the very same BASH version. If so, they *should* be the very same binaries and have the same capabilities. /bin/sh *IS* bash version 3.2.48 as is /bin/bash. And, yes I know you can vary behavior of a program depending on the value of $0 (the invocation name). AND if that were the case then there'd be no need for two binaries. A symlink or hardlink would be sufficient for the desired result. Further, if /bin/bash is a SUPERSET of /bin/sh it should be fully backward compatible with /bin/sh behavior and capability. Clearly in this case it is not. -- thepixelfreak
From: thepixelfreak on 26 May 2010 16:38 On 2010-05-26 12:48:26 -0700, Jim Gibson <jimsgibson(a)gmail.com> said: > In article <2010052612175316807-not(a)dotcom>, thepixelfreak > <not(a)dot.com> wrote: > > >>>> Any idea what's going on here? >>> >>> Not really, except that echo is a built-in command, depends on the >>> shell of which it is a part, and bash and sh are different. >> >> they clearly behave differently, but GNU would have you think they are >> the very same binary. >> >> sh-3.2# /bin/sh --version >> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) >> >> sh-3.2# /bin/bash --version >> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > > They would be the same binary if both /bin/sh and /bin/bash pointed to > the same file, or separate files that were exact copies of each other. > They are not, so it is not exactly accurate to call them the "same > binary". Sure, I know they differ. My gripe is the --version output. It's a minor gripe. > > What it looks like is that both are based on the same source release, > and sh is actually a version of bash, but with its behavior modified to > match the historical behavior of sh. > > You can specify the shell to use in the first line (you probably know > that already.) You can find out which shell is running with the $0 > variable. That will allow you to use the correct version of shell > built-ins where they differ, but that is a royal pain. Yep. > > Sorry, can't help any more than that. -- thepixelfreak
From: Bob Harris on 26 May 2010 22:30
In article <2010052613342216807-not(a)dotcom>, thepixelfreak <not(a)dot.com> wrote: > On 2010-05-26 12:27:13 -0700, Jolly Roger <jollyroger(a)pobox.com> said: > >>> > >>> Bash is a superset of sh. > >> > >> Really? > >> > >> sh-3.2# /bin/sh --version > >> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > >> > >> sh-3.2# /bin/bash --version > >> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > > > > Yes, really: > > > > <http://www.faqs.org/docs/bashman/bashref_122.html> > > > > <http://en.wikipedia.org/wiki/Bourne_shell> > > > > <http://en.wikipedia.org/wiki/Bash> > > I'm very well aware that bash is a superset of bourne shell. My gripe > is that the binaries provided by Apple both show the very same BASH > version. If so, they *should* be the very same binaries and have the > same capabilities. Maybe it the authors of bash. The following is from a commercial Redhat Linux distribution: % /bin/sh --version GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc. % /bin/bash --version GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc. I get similar --version results from a bash 4.0.0 release, which I compiled. I suspect that same is going to happen on any system using bash as both the POSIX /bin/sh and /bin/bash. > /bin/sh *IS* bash version 3.2.48 as is /bin/bash. And, yes I know you > can vary behavior of a program depending on the value of $0 (the > invocation name). AND if that were the case then there'd be no need for > two binaries. A symlink or hardlink would be sufficient for the desired > result. > > Further, if /bin/bash is a SUPERSET of /bin/sh it should be fully > backward compatible with /bin/sh behavior and capability. Clearly in > this case it is not. Again, I suggest you take you issues to the bash authors. |