Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14467
| From | Bize Ma <binaryzebra@gmail.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Unexpected delay in using arguments. |
| Date | 2018-08-12 03:16 -0400 |
| Message-ID | <mailman.5025.1534058199.1292.bug-bash@gnu.org> (permalink) |
Try this script:
#!/bin/bash
TIMEFORMAT='%R'
n=1000
m=20000
f1 () { :; }
f2 () { i=0; time while [ "$((i+=1))" -lt "$n" ]; do : ; done
i=0; time while [ "$((i+=1))" -lt "$n" ]; do f1 ; done
}
test1() { set -- $(seq $m)
f2 ""
f2 "$@"
}
test1
To get:
0.019
0.028
0.019
19.204
Which is a thousand times slower.
Bash 5 is even worse, try:
time b50sh -c 'f(){ :;};for i do f; done' {0..500}
real 0m20.709s
user 0m19.856s
sys 0m0.024s
Read more detail here:
https://unix.stackexchange.com/questions/462084/bash-has-troubles-using-argument-lists
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Unexpected delay in using arguments. Bize Ma <binaryzebra@gmail.com> - 2018-08-12 03:16 -0400
csiph-web