bug-bash
[Top][All Lists]
Advanced

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

Re: is it a bug


From: L A Walsh
Subject: Re: is it a bug
Date: Mon, 16 Nov 2020 22:36:48 -0800
User-agent: Thunderbird

On 2020/11/16 11:02, Alex fxmbsw7 Ratchev wrote:
on my way for a new paste
Anytime you start going over multiple lines in an alias, you
need to consider the use of a function, where 'need' would ideally
increase in proportion to the number of lines you are including.

For increased readability, I took out 'aal' being prepended to
every variable except the two usages of 'aal[...]' where I substituted
'foo' for 'aal'.  NOTE: the code seems to use 'foo' (or 'aal') without it
being initialized.
The main oddity I found was that if (in my version),
   t=""
is on the same line as 'res=()', I get the error with unexpected ';'
since it doesn't seem to parse the 'for' statement's "for", so the
semi after it is unexpected.

For some strange reason, the parsing of the array doesn't break off
at the space, in fact, when the lines are split, the alias seems
to lose some spacing (note 'res=t='):

 executing alias +ax
 res=t=
 alias -- "t="

This seemed to be the minimum difference between a working & non working
case.  Either (for no error):
 an_alias='res=()
           t=""
           for ci in "${!foo[@]}"; do \

or (to reproduce error):
 an_alias='res=() t=""
           for ci in "${!foo[@]}"; do \

error I got was:
./aldef.sh: array assign: line 23: syntax error near unexpected token `;'
./aldef.sh: array assign: line 23: `res=() t=""

It is doing something weird -- I suspect that
alias expansion is expanding the right side as 'text' and not
as code that gets interpreted when the substitution occurs.

Try reserving aliases where it is needed (something a function can't do)
or where it helps legibility.

Hope this helps...oh....including the version that gives an error.
To see version that works, split the 't=""' to be on the line
below the 'res=()'.

-linda



Attachment: aldef.sh
Description: Bourne shell script


reply via email to

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