bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed


From: Stephane Chazelas
Subject: Re: sed
Date: Tue, 13 Feb 2007 20:47:07 +0000
User-agent: Mutt/1.5.6i

On Tue, Feb 13, 2007 at 10:19:20AM -0600, Matthew Woehlke wrote:
> Stephane Chazelas wrote:
> >and use $(...) instead of `...`
> ...
> >6- use the standard sh syntax instead of trying to rely on any
> >version and implementation of an unspecified shell like ksh or
> >bash (and have bash or ksh interpret that syntax if you wish as
> >those are standard conformant shells).
> 
> Funny that you say that, when you previously recommended using the 
> non-portable $() construct. :-)
[...]

Above, I said "standard", not "portable". Standards are a way to
achieve portability in a clean way.

Using standards is also the easy way: if your script conforms to
the text of the standard, then your script is guaranteed to run
on standard compliant systems, and if it's not, then it's a bug
in the system, not in your script.

To write portable code without the help of standards means do to
a full coverage test on every system you plan the code to be
coded to.

The POSIX and Unix standards define $(...) for command
substitution. If your system's standard sh doesn't recognise
$(...), then it's not POSIX compliant, then it's a bug of the
system if that system claims POSIX compliance (as Unix-like
have been doing for decades).

The Bourne shell is a legacy shell, just as the Thomson shell
was before it. You don't need to make scripts portable to that
shell anymore unless you want to support 15 year old systems,
such as you don't need to make scripts portable to the Thomson
shell unless you want to support 35 year old systems.

Thanksfully, nowadays, sh's (and Unix utilities') syntax is
described by a (several) norm(s), such as C is described by a
norm. Though those norms/specifications are far from being
perfect or having no issues, it makes it a lot easier to write
portable scripts.

Which is why it makes me a bit sad when I see the number of
websites that advertise bash programming or ksh programming.

-- 
Stéphane




reply via email to

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