NetBSD-Users archive

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

Re: ksh and brace expansion



 | In my opinion, let sh be a posix shell, let ksh be a korn shell.

That is kind of amusing.   The POSIX shell is based upon the Korn
shell (ksh88) - of which our /bin/ksh (which is an old pdksh) is a
re-implemented clone (modulo bugs in each of them).

What I mean is do not worry so much to make ksh POSIX compliant by
default. In my opinion is better to do that just with sh.

POSIX did delete (as in fail to specify, while leaving it open for
implementations to include, by reserving some "words" that portable
scripts should never use) some of the more esoteric ksh8 features
(the select keyword, the REPLY variable, the absurdly ugly _ var, and
more) but did retain some of the even worse features (cd -L for example)

It is quite a shame that rc didn't become popular. I love how it
handle the quoting mess, and is so simple, reading the man page
was a pleasure. But (almost) nobody uses it...

that /bin/sh (which started as a clone of the original Bourne shell, but
has had much of what POSIX requires added) does not (will not) support.

From sh(1) I thought that the the goal was for sh to be POSIX.

[...]
sh is the standard command interpreter for the system.  The current
version of sh is in the process of being changed to conform more closely
to the POSIX 1003.2 and 1003.2a specifications for the shell.
[...]

ps: I have no idea why anyone would call brace expansion "alternation",
there are no alternatves, nothing really alters, it is just one more, purely
rote (as in the input exactly specifies the output, nothing else influnces
the results) expansion method, which is sometimes convenient in interactive
mode, and simply an abomination in scripts.

I suppose that it is because the the words are created repeating
the first and last part alternating the elements in the brackets
in between.

An example where it seams useful, is when a command takes the same
option several times with different arguments:

command --optionwithlongname={one,two,three}

As I said I really don't like those fancy things. It makes more
complicated something complicated enough already.  But sometimes
I encounter this, for example copying parts from other scripts
written in bash, thinking that it will work in ksh.

I didn't expect brace expansion disable by default.

Reading again the man page (just 2886 lines...), it is clear
that posix can be on by default, although not recommended:

[...]
(The shell can also be compiled so that it is in POSIX mode by
default, however this is usually not desirable)
[...]

I deserve a knock on the head for passing the man page
too fast.

adr.


Home | Main Index | Thread Index | Old Index