[Top][All Lists]

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

Re: Redirection between assignment statement and command name prevents a

From: Oğuz
Subject: Re: Redirection between assignment statement and command name prevents alias substitution
Date: Wed, 24 Mar 2021 11:15:11 +0300

24 Mart 2021 Çarşamba tarihinde Robert Elz <kre@munnari.oz.au> yazdı:
> At least in the NetBSD sh, as soon as the \n that comes from the
> expanded P2B is seen, the shell switches to heredoc input reading,
> which doesn't read tokens at all, just lines until the end delimiter
> is seen.   There's absolutely no chance that any aliases can be found
> in there ("P3" is yet to be read at that point - it simply becomes part
> of the heredoc).

This makes sense, and other shells seem to agree too; some take end-of-file
as the end delimiter and print the rest (` P3'), others complain about
missing delimiter. Both good to me.

> The current way is simpler, everything just kind of fits (the shell
> already needs the mechanism to switch to reading from an internal
> string, to handle eval, and traps, aliases use the same mechanism).
> So, just stick the alias value into the input stream as a string, and
> continue as if nothing happened (with the extra bookkeeping that
> aliases require of course).

Yeah. But it is also hard to explain how alias substitution works in detail
given the abundance of corner cases with which each shell deals in its own
odd way. Anyway, thanks. I think I got the general idea of aliases now

> kre

reply via email to

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