bug-bash
[Top][All Lists]
Advanced

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

Re: Redirection between assignment statement and command name prevents a


From: Robert Elz
Subject: Re: Redirection between assignment statement and command name prevents alias substitution
Date: Wed, 24 Mar 2021 04:25:32 +0700

    Date:        Tue, 23 Mar 2021 20:27:27 +0200
    From:        =?UTF-8?B?T8SfdXo=?= <oguzismailuysal@gmail.com>
    Message-ID:  
<CAH7i3LpbRhpQ+S1-YAzCDoy_Yyep738d5JEVb572tVOQP0AAhQ@mail.gmail.com>

  | Apparently I couldn't make myself clear there,

Perhaps, or I was just failing to understand.   Never mind.
But this (as you know) was nothing like I imagined you meant.

  | # doesn't work anywhere
  | P1 P2B P3

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).

 | I thought it would keep fetching tokens until reaching one that can't
 | be an alias or is an alias but doesn't have a space at the end,
 | and then go back to the first expanded string and continue from there.

It might be possible to do it that way, I haven't really thought about
the implications (aside from duplicating all of the alias values, in the
alias table, and in the input stream), and certainly haven't tried it.
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).

kre




reply via email to

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