Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #13766 > unrolled thread

Double substitution issue

Started byWilliam Entriken <fulldecent@gmail.com>
First post2018-02-28 03:25 -0500
Last post2018-11-21 08:37 -0500
Articles 3 — 3 participants

Back to article view | Back to gnu.bash.bug


Contents

  Double substitution issue William Entriken <fulldecent@gmail.com> - 2018-02-28 03:25 -0500
    Re: Double substitution issue fulldecent@gmail.com - 2018-11-20 20:16 -0800
      Re: Double substitution issue Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-21 08:37 -0500

#13766 — Double substitution issue

FromWilliam Entriken <fulldecent@gmail.com>
Date2018-02-28 03:25 -0500
SubjectDouble substitution issue
Message-ID<mailman.9859.1519829279.27995.bug-bash@gnu.org>
This behavior is different in zsh and bash, and maybe bash behavior is a
bug.

# Test case

touch 1 2 3
cat > script.sh <<EOL
from=1
to=3
ls {$from..$to}
EOL
chmod a+x script.sh

bash ./script.sh

zsh ./script.sh

# Expected

Both list files 1, 2, 3

# Actual

zsh passes.

Bash fails the chained substitution with:

ls: {1..3}: No such file or directory

[toc] | [next] | [standalone]


#14837

Fromfulldecent@gmail.com
Date2018-11-20 20:16 -0800
Message-ID<c44e4f88-7c8f-4a54-9f1e-762913c5f70c@googlegroups.com>
In reply to#13766
Thank you for explaining this fine point. 

I have found a way to use double expansion, and of course this is not safe 
in all contexts: 

    from=1;to=3;eval echo {$from..$to} 

Regards, 
Will 

[toc] | [prev] | [next] | [standalone]


#14838

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-11-21 08:37 -0500
Message-ID<mailman.4382.1542807491.1284.bug-bash@gnu.org>
In reply to#14837
On Tue, Nov 20, 2018 at 08:16:47PM -0800, fulldecent@gmail.com wrote:
> I have found a way to use double expansion, and of course this is not safe 
> in all contexts: 
> 
>     from=1;to=3;eval echo {$from..$to} 

for ((i=from; i<=to; i++)); do
  ...
done.

[toc] | [prev] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web