Op 29-09-17 om 14:16 schreef Stephane Chazelas:
> 2017-09-29 11:59:52 +0200, Martijn Dekker:
> [...]
> 
> Ouch, quite of lot of nasty bugs. Have you reported them to
> Solaris?

No, because I thought ksh88 is no longer being developed. Is that incorrect?

Where/how would I report Solaris bugs?

>> * FTL_BRACSQBR: a bracket glob pattern containing a quoted closing
>> square bracket ']' is never matched, not even if that character is
>> escaped or passed from a quoted variable. For example,
>>      case ] in [a\]b] ) echo ok;; * ) echo bug;; esac
>>      case a in [a\]b] ) echo ok;; * ) echo bug;; esac
>>      case b in [a\]b] ) echo ok;; * ) echo bug;; esac
>> all output 'bug'.
> 
> Is that specified by POSIX? I have that notion that "]" can only
> be included in a set if used as the first character ([]ab]).
> 
> I understand that quotes remove the special meaning of glob
> operators, but that's not clear to me what should happen if
> you're quoting only part of that [...] operator.

My understanding is that a backslash should remove the special meaning
of the following character, in this case the first ']'. But note that
quoting all of it doesn't work either on ksh88:

case ] in ['a]b'] ) echo ok;; * ) echo bug;; esac
var=a]b; case ] in ["$var"] ) echo ok ;; * ) echo bug ;; esac

both still output "bug".

In fact, so does

var=]ab; case ] in ["$var"] ) echo ok ;; * ) echo bug ;; esac

Even moving ']' to the start of a variable will not make it work.

2010 versions of ksh93 have this bug as well, and they are still seeing
some considerable use. But it's fixed in 2012 versions.

> ksh88's [a\]b] matches on [a]b].

I'm not sure what you mean there.

> older versions of zsh don't match "-" with [a\-b]

Older versions of zsh (< 5.0.7) have lots of other fatal bugs as well.

> ksh93 matches "\" with ["^"c]

Remember the negator in POSIX glob bracket patterns is !, not ^. But
yes, that ksh93 bug has modernish ID BUG_BRACQUOT. Even if a '!' or '^'
is passed in a quoted variable it's still interpreted as a negator. (I
discovered that bug myself some time ago because it requires a
workaround for the trim() function in the var/string modernish module.)

> ksh93 and zsh match "b" with [[:alpha\:]] (mksh matches neither
> "a]" nor "b" nor "[[:alpha:]]")

mksh does not have character classes at all (BUG_NOCHCLASS); this is a
design decision on Thorsten's part.

> [...]
>> * FTL_PARONEARG: When IFS is empty (i.e. field splitting is off), "$@"
>> is counted as a single argument instead of each positional parameter as
>> separate arguments. In other words, "$@" does not *generate* fields when
>> field *splitting* is disabled (which is of course illogical and POSIX
>> has rightly fixed this).
> 
> Same bug as in the Bourne shell. I hadn't realised it was also
> in ksh88.

It's in early ksh93 versions as well.

> [...]
>> * BUG_HDPARQUOT: Quotes within parameter substitutions in Here-Documents
>> aren't removed. For instance, if 'var' is set, ${var+"x"} in a here-
>> document erroneously yields "x", not x.
> 
> Is that specified?

As far as I know, is not specified that they should act any differently
just because they're in a here-document, so I think by default that
should be considered a bug. (The only other shell I've found that acts
like this is FreeBSD sh, which is otherwise nearly bug-free.)

>> * BUG_PP_08: When IFS is null, unquoted $* within a substitution (e.g.
>> ${1+$*} or ${var-$*}) does not generate one field for each positional
>> parameter as expected, but instead joins them into a single field.
> 
> IIRC that was clarified as "unspecified" recently.

I see. Do you (or does anyone) have a link?

>> * BUG_PSUBBKSL: A backslash-escaped character within a quoted parameter
>> substitution is not unescaped, e.g.
>>      echo "${foo-\x}"
>> outputs '\x' instead of 'x'.
> [...]
> 
> Not sure about that one, there have been extensive discussions
> on similar matter in the past few years.

Hmm. Yeah, this one is probably wrong. Most shells treat \} differently
from other backslash-quoted characters.

unset -v foo; printf '%s ' "${foo-\}}" "${foo-\x}" "${foo-\\}"

bash 3.2, dash:
\} \x

bash 4.4, ksh93, mksh, zsh, FreeBSD sh, dash (Debian patched):
} \x

yash, oksh:
} x

As far as I can tell, POSIX only says this about it:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
| Any '}' escaped by a <backslash> or within a quoted string, and
| characters in embedded arithmetic expansions, command substitutions,
| and variable expansions, shall not be examined in determining the
| matching '}'."

I will have to do a search on those discussions. Thanks.

- M.

Reply via email to