Op 08-03-17 om 23:02 schreef Thorsten Glaser:
> Martijn Dekker dixit:
> 
>> only happen for real shell assignments (i.e. not even with
>> assignment-like arguments to "export" and the like).
> 
> No, this is an actual and documented feature, and changing
> this would break too many users (even special-casing export,
> typeset, etc. is a no-go).

Then the documentation is not consistent with the intended behaviour. If
it's intended that any argument ending in an unquoted sequence =~, given
to any command, is subject to tilde expansion, the documentation should
describe exactly that behaviour.

| Tilde expansion
[...]
|   In parameter assignments (such as those preceding a simple-command or
|   those occurring in the arguments of alias, export, global, readonly
|   and typeset), tilde expansion is done after any assignment (i.e.
|   after the equals sign) [...]

The manual page specifically states that tilde substitution (only)
happens in parameter assignments. But:

* Arguments to builtins are not actually parameter assignments in shell
grammar terms. Differences in behaviour remain even though mksh parses
arguments to the listed builtins specially, e.g. "a"=b does not work as
a parameter assignment but typeset "a"=b does cause typeset to perform
an assignment.

* Aliases aren't parameters at all, so the 'alias' builtin does not
belong in that list.

* There is no possible way in which the argument to "echo" in my
original report could validly be construed as a parameter assignment
(even allowing for the inaccurate use of the term).
$ echo "some arbitrary stuff "=~
1. "echo" never interprets its arguments as directives to preform an
assignment.
2. Even if it did, the supposed parameter name is not valid as either a
parameter name or an alias name.

- M.

Reply via email to