On 2022-12-19 22:58:44 +0100, наб wrote:
> This makes dash, as you note, incompatible with ksh93 and bash,
> but compatible with zsh in this regard. Seeing as this is an extension
> to POSIX (which requires that the name matches [a-zA-Z0-9_!%,@]+),
> both approaches are valid.

No, it is still incompatible with zsh, where one can use the alias:

zira% alias '\mv=echo ab'
zira% alias
'\mv'='echo ab'
run-help=man
which-command=whence
zira% \mv
ab
zira% 

But perhaps if an alias with a backslash is accepted like in zsh,
then the fact that it is not used by dash is a bug. This doesn't
match the dash man page:

   Aliases
     An alias is a name and corresponding value set using the alias(1)
     builtin command.  Whenever a reserved word may occur (see above),
     and after checking for reserved words, the shell checks the word
     to see if it matches an alias.  If it does, it replaces it in the
     input stream with its value.  [...]

and about the backslash:

   Backslash
     A backslash preserves the literal meaning of the following character,
     with the exception of ⟨newline⟩.  A backslash preceding a ⟨newline⟩
     is treated as a line continuation.

But backslash handling is normally done *after* checking for aliases.
This typically allows one to disable an alias by using a backslash:

$ alias foo="echo ab"
$ foo
ab
$ \foo
dash: 3: foo: not found
$ f\oo
dash: 4: foo: not found

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to