bug-bash
[Top][All Lists]
Advanced

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

Re: Problem with sequences with variables?


From: Chet Ramey
Subject: Re: Problem with sequences with variables?
Date: Wed, 28 Apr 2021 21:17:28 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

On 4/28/21 7:02 PM, Tom (AST) Watson via Bug reports for the GNU Bourne Again SHell wrote:
Hi...

I was trying to do some sequences, and it looks like they don't like variables. 
 See the following:

Brace expansion happens first, before any of the other word expansions, so
it requires integer constants or alphabetic literals.

[user@box3 ~]$ echo $BASH_VERSION
5.0.17(1)-release
[user@box3 ~]$ echo {1..10}
1 2 3 4 5 6 7 8 9 10
[user@box3 ~]$ echo $l
10
[user@box3 ~]$ echo {1..${l}}
{1..10}
[user@box3 ~]$

Shouldn't the second sequence echo be the same as the first sequence echo?  It 
would be MUCH more useful if it were.

Maybe, but it's never worked that way and was never intended to. You can
get what you need using eval:

eval echo \{1..${i}}

--
``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]