tech-userlevel archive

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

Re: Coming changes to /bin/sh

    Date:        Mon, 8 May 2017 21:05:11 +0200
    From:        Edgar =?iso-8859-1?B?RnXf?= <>
    Message-ID:  <>

  | > Does anyone have any objections to that?

[ "that" is no longer accepting invalid uses of the '!' reserved word.]

  | No. Unless there are enough #!/bin/sh scripts out there that rely on the 
  | broken syntax

I very much doubt it.

  | (and don't already rely on [[ or whatnot).

If they need bash, then ...

$ bash -c 'ls | ! grep foo | cat'
bash: -c: line 0: syntax error near unexpected token `!'
bash: -c: line 0: `ls | ! grep foo | cat'

they have already been broken.  Even...

$ dash -c 'ls | ! grep foo | cat'
dash: 1: Syntax error: "!" unexpected
$ yash -c 'ls | ! grep foo | cat'
yash -c:1: syntax error: `!' cannot be used as a command name
$ zsh -c 'ls | ! grep foo | cat'
zsh:1: parse error near `!'


$ sh -c 'ls | ! grep foo | cat'

is very much in the minority (though ksh also allows it, both our
version, and ksh93 - ksh93 has a lot of extended syntax, it might even
be meaningful there.)


Aside: while speaking of !, our sh has another bug in this area, which I
am not sure whether to waste time fixing ...

	! ! command
should guarantee that $? is set to 0 or 1, 0 if the command "succeeded"
(exited with 0 exit status), and 1 otherwise (whatever the non-zero exit
status of command was).

But our implementation simply counts the '!' prefixes to a command, and
if there are an odd number, implements "not", otherwise does nothing...
(actually it doesn't even count, it just toggles a "need a not" switch
every time it sees '!').

And no, nothing I am aware of in the real world actually cares about
this one either.   (Some test suites might.)

It is fixable (probably 20 minutes of coding, maybe just 10 since I already
know what needs to be done to do it properly, and then some testing),
but is it worth it?

Home | Main Index | Thread Index | Old Index