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: Alex fxmbsw7 Ratchev
Subject: Re: Incorrect alias expansion within command substitution
Date: Sat, 5 Feb 2022 21:54:31 +0100

it would make the whole work at alias level
alias (symbolic) 1=$(( 2=1+2 3=+ 4=1+2 5=))
1 2 3 4 5
works
[i wish]

On Sat, Feb 5, 2022 at 9:46 PM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 2/5/22 3:44 PM, Alex fxmbsw7 Ratchev wrote:
> > On Sat, Feb 5, 2022 at 9:39 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 
> > wrote:
> >>
> >> On Sat, Feb 5, 2022 at 7:55 PM Chet Ramey <chet.ramey@case.edu> wrote:
> >>>
> >>> On 2/4/22 6:17 PM, Alex fxmbsw7 Ratchev wrote:
> >>>> what about this viewing point
> >>>> aliases can start, $(('s, but not end... this is unlogic
> >>>
> >>> Well, I don't know about `unlogic' but there's an understanding deficit,
> >>> for sure.
> >>>
> >>>>
> >>>> alias -- \
> >>>> p='printf %s\\n ' \
> >>>> assign='assign=$(( ' begin='$(( ' \
> >>>>
> >>>> for data in "1 + 2"
> >>>> do
> >>>> alias -- data="$d "
> >>>> p begin data ))
> >>>> done
> >>>>
> >>>> this works and results 3
> >>>
> >>> OK, let's go through it. I'll gloss over some non-essential details and
> >>> simplify others. I'll skip over the bulk of the for loop parsing and just
> >>> cover the simple command where alias expansion takes place.
> >>>
> >>> Since `p' is in a command position, it gets alias expanded to
> >>> `printf %s\\n '. The lexical analysis restarts, the two words get scanned,
> >>> and we start a simple command. The expansion ends with a space, so the 
> >>> next
> >>> token (`begin') undergoes alias expansion, gets expanded to `$(( ', and 
> >>> the
> >>> lex restarts. We read `$((' and know we're reading the start of a word 
> >>> that
> >>> begins with an arithmetic expansion. We keep reading as if we are reading 
> >>> a
> >>> double-quoted string, looking for `))', since that's what you do while
> >>> reading an arithmetic expansion.
> >>
> >> so the alias expansion fails at the current command is no alias
> >> anymore, so alias parsing rules dont apply anymore, .. no ... hmm .. ?
> >> would make much sense then and i have nothing else to say..
> >
> > maybe ask about an shopt feature to enable straight alias expansion
> > when the aliases are following ..
>
> How would that, whatever it is, help you here?
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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