2019-01-27 02:29:04 +0000, Harald van Dijk: [...] > This proposed resolution does not leave empty aliases (aliases not resulting > in any token) unspecified. I mentioned them before, because they are > mishandled by at least one shell: > > $ dash -c 'alias empty= > empty' > dash: 2: Syntax error: end of file unexpected > > I'd be perfectly okay with considering that a bug in dash (I personally > consider it exactly that, and it's easy to fix), but I do not know whether > there are different situations in other shells that also fail for other > reasons and require major changes to their implementations of aliases to > solve. [...]
But then again alias empty= { empty; } or (empty) Also fails in many shells (and don't fail in some shells where { ;} or () otherwise fails). The problem is not that much about empty aliases here but about when alias expansion results in no command where that's not expected. Empty aliases are useful and often used in things like: if [ "$DEBUG" ]; then alias ifdebug= else alias ifdebug='#' fi ifdebug log "$(cmd)" If it were implemented with a function instead, cmd would still be run. aliases avoids that but you need to remember to keep your debug commands on a single line. And dash has no issue with that code. I'd say it's unlikely for the dash issue (which I'd agree to call a bug) to be hit in practice though you could imagine convoluted things like: if [ "$DEBUG" ]; then alias ifdebug= endifdebug= else alias ifdebug='if false; then' endifdebug=fi fi ifdebug cmd endifdebug -- Stephane