Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #13766 > unrolled thread
| Started by | William Entriken <fulldecent@gmail.com> |
|---|---|
| First post | 2018-02-28 03:25 -0500 |
| Last post | 2018-11-21 08:37 -0500 |
| Articles | 3 — 3 participants |
Back to article view | Back to gnu.bash.bug
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
| From | William Entriken <fulldecent@gmail.com> |
|---|---|
| Date | 2018-02-28 03:25 -0500 |
| Subject | Double 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]
| From | fulldecent@gmail.com |
|---|---|
| Date | 2018-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]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2018-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