[svlug] Evil Backquotes (was Re: how to copy a bunch of "." files?)

Tin Le tin at le.org
Sun May 14 16:22:08 PDT 2000


-----BEGIN PGP SIGNED MESSAGE-----


> > > As far as I know, they're non-standard -- they certainly they don't
> > > work in many ksh's.  And they're hard for the eye to distinguish from

> > AFAIK, ksh isn't as widely-used as bash/sh or csh.

> Certainly not on linux, but on *NIXen as a whole, I think it may be
> more widely used than bash.  Or at least was, once.

The dateline is something like this:  the original Bourne shell, then
csh from Berkeley distribution.  Although csh does not shows up in the
AT&T variants of UNIX till System III.  Some vendors distro do include
csh.

Ksh (Korn shell) came around 1986 (outside of Bell Lab that is) from David
Korn.  At that point, ATT realized too late that they could make money off
of UNIX.  Before that time, they were giving out source code license for
practically nothing.  So they demanded a lot of money for ksh.  I know, I
tried to license it to port it for several of the companies I was working
for at the time.

That's when people decided to work on public domain version of ksh, and I
believe bash also start to come about because of the ATT licensing issue.

Tcsh derived from csh.

> > csh still seems to be a 'standard' shell

> I'm glad you put that in quotes.  It's a "standard" like MS-Word is a
> "standard".  And I'm not sure which I dislike more.  :-)

> With csh, you must use backticks -- but then a sensible person isn't
> using csh (or tcsh) in the first place.  And even if you are, you're
> not worried about compatibility with any of the bourne-like shells.

It went back a long way.  The way I was taught was that sh is for writing
scripts and csh is only for interactive use.  One of the reason you do
not write shell scripts with csh is that csh is fairly buggy when it comes
to scripting.  Its behavior is not consistent.  Secondly, because csh
is not available on all systems, you can not depend on your script running.

However, sh (Bourne) is guaranteed to be on _ALL_ systems.  You'd be amazed
at how sophisticated sh scripts can be.  Especially those using the more
recent versions of sh.  The early sh was very primitive, i.e. no shell
functions (so it was emulated via external scripts that get called).

> > Bash is pretty standard at least on Linux, and backquotes work there,
> > and I suspect they work equally well in other sh-compatible shells, 

> No, they don't.  Older bourne shells often don't support the feature
> at all, with any syntax.  And ksh, which is still pretty popular, is
> compatible with those older bourne shells, but introduced the
> now-standard and simply more elegant $() syntax.

You would have to go back pretty far to find a system still running
versions of sh that does not support the back tick.  Beginning with SysIII
UNIX, Bourne shell gained shell functions and a number of other useful
features designed to help writing scripts.  SysIII came out around 1984-5
timeframe I think.

> Basically, what it comes down to is that any bourne-like shell which
> supports the feature will provide the $() syntax, but a few won't
> provide the backticks syntax.  Since the $() is preferable for other
> reasons *and* slightly more common, why not use that?

I can't speak for other people, but I tried to write portable scripts that
will run in Bourne shell.  If it run in sh, it will run in bash and ksh.
This mean avoiding unneeded features like the plague.

It's habit from having to port large software... :-)  After one swears at
the dunderheads that used a feature in a system, that is going to cost
me a couple days to port...

The world is not Linux, nor is it NT, nor is it Solaris.

> > It's simply a very nice feature, useful in many situations.

> I'm not dissing the feature, merely the syntax.  Both backticks and
> $() provide the feature.  And backticks are harder to read, less
> flexible, and slightly less standard.

Agreed.  There is a time and place to use it.

Cheers,
Tin Le

- ----
http://tin.le.org
Internet Security and Firewall Consulting
Tin Le - tin at le.org

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i

iQCVAgUBOR81HhiIIbPkDHhBAQGC2AQAlCRRBDOTufbGc93rBLm94nJ3phHbs5ea
dSnPaqg//hEj21MFX47CzjJ1y/+YJRuzfC+6P7VSEVWD9vntVplZcRmJ1ze2rQDx
1wKJ+Mp2D2uBa6c1sbHuUQEiE2q4rlhaRlEjQRzdmj3qoj8rKt8d6eRXI3mLh0M8
sqe3A3t64Lc=
=Ly+u
-----END PGP SIGNATURE-----






More information about the svlug mailing list