[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [platform-testers] new snapshot available: sed-4.4.104-290c

From: Nelson H. F. Beebe
Subject: Re: [platform-testers] new snapshot available: sed-4.4.104-290c
Date: Fri, 30 Mar 2018 08:20:13 -0600

Paul Eggert writes on Tue, 27 Mar 2018 18:38:54 -0700:

>> ...
>> >       test=${1##*/}
>> >
>> > I would strongly urge removal of such shell extensions.
>> That syntax has been standard ever since POSIX formalized the shell in
>> IEEE Std 1003.2-1992 (I just pulled out my trusty printed copy and
>> checked). It's a bit of a stretch to call it an "extension" 26 years
>> after standardization.
>> ...

I just looked up that standard (page 37) and tried its several
examples with /bin/sh on Solaris 10.  To my surprise, some of them
produced errors, and not the output shown in those examples.

I then repeated the experiment with /usr/xpg4/bin/sh, and they
worked as shown in POSIX.

Next, I looked at the manual page for sh:

       The /usr/bin/sh utility is a command programming language that executes
       commands read from a terminal or a file.

       The /usr/xpg4/bin/sh utility is a standards compliant shell. This util-
       ity provides all the functionality of ksh(1), except in cases discussed
       in ksh(1) where differences in behavior exist.

So, Solaris 10 /bin/sh is not fully in accord with POSIX, and thus
remains the most `primitive' shell that we have to deal with in
practice.  I suspect that we'll be running Solaris 10 systems for at
least another five or so years at my site.

I've always found the shell's ${parameter<OPERATOR>word} expansion
rules hard to remember, and so, instead of

        $ x=/one/two/three
        $ echo ${x##*/}

I normally use

        $ basename $x

- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: address@hidden  -
- 155 S 1400 E RM 233                       address@hidden  address@hidden -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -

reply via email to

[Prev in Thread] Current Thread [Next in Thread]