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


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

Unexpected delay in using arguments.

Started byBize Ma <binaryzebra@gmail.com>
First post2018-08-12 03:16 -0400
Last post2018-08-12 03:16 -0400
Articles 1 — 1 participant

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


Contents

  Unexpected delay in using arguments. Bize Ma <binaryzebra@gmail.com> - 2018-08-12 03:16 -0400

#14467 — Unexpected delay in using arguments.

FromBize Ma <binaryzebra@gmail.com>
Date2018-08-12 03:16 -0400
SubjectUnexpected delay in using arguments.
Message-ID<mailman.5025.1534058199.1292.bug-bash@gnu.org>
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

[toc] | [standalone]


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


csiph-web