From: Chris F.A. Johnson on
On 2010-05-15, Thomas 'PointedEars' Lahn wrote:
> Stephane CHAZELAS wrote:
>
>> Chris F.A. Johnson:
>>> On 2010-05-14, WH wrote:
>> [...]
>>>> In bash, we can use 'case' statement so do some simple string matching.
>>>> For example
>>>>
>>>> read quit
>>>> case "$quit" in
>>>> Y*|y*|"")
>>>> exit 1
>>>> ;;
>>>> *)
>>>> ;;
>>>> esac
>>>>
>>>> If we don't want to use case (since the condition is simple),
>>>
>>> Why would you not want to use case? It *is* simple, and it's
>>> portable.
>>
>> Seconded.
>>
>> Another portable though not as legible one:
>>
>> [ "${quit#[yY]}" ] || exit
>
> When I suggested that in de.comp.os.unix.shell, it has been brought to my
> attention that by contrast it is unfortunately _not_ portable (at least not
> as portable as `case') even though SUSv3 specifies it. I have been told
> that this feature was only introduced with the first ksh versions (which
> explains why it is in SUSv3, and bash), and I have subsequently found out by
> reading the original sh documentation that it is not Bourne-shell
> compatible.

The Bourne shell is not portable. The most portable shell is the
standard Unix shell (i.e. a POSIX shell).

--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====
From: Thomas 'PointedEars' Lahn on
Chris F.A. Johnson wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Stephane CHAZELAS wrote:
>>>> Why would you not want to use case? It *is* simple, and it's
>>>> portable.
>>>
>>> Seconded.
>>>
>>> Another portable though not as legible one:
>>>
>>> [ "${quit#[yY]}" ] || exit
>>
>> When I suggested that in de.comp.os.unix.shell, it has been brought to my
>> attention that by contrast it is unfortunately _not_ portable (at least
>> not as portable as `case') even though SUSv3 specifies it. I have been
>> told that this feature was only introduced with the first ksh versions
>> (which explains why it is in SUSv3, and bash), and I have subsequently
>> found out by reading the original sh documentation that it is not Bourne-
>> shell compatible.
>
> The Bourne shell is not portable. The most portable shell is the
> standard Unix shell (i.e. a POSIX shell).

ISTM you have no clue what you are talking about.


PointedEars
From: Barry Margolin on
In article <858embF9itU1(a)mid.individual.net>,
"Chris F.A. Johnson" <cfajohnson(a)gmail.com> wrote:

> On 2010-05-15, Thomas 'PointedEars' Lahn wrote:
> > Stephane CHAZELAS wrote:
> >
> >> Chris F.A. Johnson:
> >>> On 2010-05-14, WH wrote:
> >> [...]
> >>>> In bash, we can use 'case' statement so do some simple string matching.
> >>>> For example
> >>>>
> >>>> read quit
> >>>> case "$quit" in
> >>>> Y*|y*|"")
> >>>> exit 1
> >>>> ;;
> >>>> *)
> >>>> ;;
> >>>> esac
> >>>>
> >>>> If we don't want to use case (since the condition is simple),
> >>>
> >>> Why would you not want to use case? It *is* simple, and it's
> >>> portable.
> >>
> >> Seconded.
> >>
> >> Another portable though not as legible one:
> >>
> >> [ "${quit#[yY]}" ] || exit
> >
> > When I suggested that in de.comp.os.unix.shell, it has been brought to my
> > attention that by contrast it is unfortunately _not_ portable (at least not
> > as portable as `case') even though SUSv3 specifies it. I have been told
> > that this feature was only introduced with the first ksh versions (which
> > explains why it is in SUSv3, and bash), and I have subsequently found out
> > by
> > reading the original sh documentation that it is not Bourne-shell
> > compatible.
>
> The Bourne shell is not portable. The most portable shell is the
> standard Unix shell (i.e. a POSIX shell).

What's most portable is the intersection of features of all the shells
in the family of shells based on Bourne. If you limit yourself to those
features, it will run in Bourne, Korn, bash, POSIX, etc.

Since most of what has happened over the years is addition of features,
I'll bet that intersection is pretty close to early Bourne shell.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***