bug-bash
[Top][All Lists]
Advanced

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

Re: Incorrect alias expansion within command substitution


From: Martijn Dekker
Subject: Re: Incorrect alias expansion within command substitution
Date: Wed, 2 Feb 2022 18:40:17 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

Op 01-02-22 om 15:23 schreef Chet Ramey:
Historically, bash (and ksh93) has favored the former. Just about all the
other shells claiming some sort of POSIX conformance favor the latter (all
the ash-based shells, yash, mksh).

What are your plans here?

I've no current plans. Any remotely plausible use of aliases is not going to be affected either way. I've done some pretty innovative stuff in modernish that involves aliases and that too would be unaffected. In my view, this difference is relevant to standards and regression test writers and probably no one else.

Having said that, I've never understood why ksh stores command substitutions as unparsed source code (including comments and all) in the parse tree and only parses that at execution time -- including in dot scripts (which are otherwise parsed in their entirety before execution) and shcomp bytecode output. That seems bizarre. It doesn't do that for regular subshells in parentheses or for process substitutions.

And ksh *still* has $(command substitution) parsing bugs -- a currently known one is https://github.com/ksh93/ksh/issues/269 and there are probably more yet to be discovered.

So, in a hypothetical future where I will finally have managed to understand the uncommented and undocumented dark magic that is the ksh parser, lexer, expansion and command substitution code, I would like to delete the lexer code that skips over a $(comsub) and instead parse comsubs the same way as regular subshells or process substitutions. Aliases would then be handled the same way as well.

Don't hold your breath though. The chances of it happening sometime this decade are low. Plus, there is still a lot of lower hanging fruit to pick in this incredibly buggy code base.

--
||      modernish -- harness the shell
||      https://github.com/modernish/modernish
||
||      KornShell lives!
||      https://github.com/ksh93/ksh



reply via email to

[Prev in Thread] Current Thread [Next in Thread]