[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:46 +0100 |
meant in more reasonable complicated codes they are more useufl
On Sat, Feb 5, 2022 at 9:54 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>
> 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/
- Re: Incorrect alias expansion within command substitution, (continued)
- Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/04
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/04
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/04
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/04
- Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
- Re: Incorrect alias expansion within command substitution,
Alex fxmbsw7 Ratchev <=
- Re: Incorrect alias expansion within command substitution, Lawrence Velázquez, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
Re: Incorrect alias expansion within command substitution, Martijn Dekker, 2022/02/02
Re: Incorrect alias expansion within command substitution, L A Walsh, 2022/02/02