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


Groups > gnu.bash.bug > #14467

Unexpected delay in using arguments.

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Bize Ma <binaryzebra@gmail.com>
Newsgroups gnu.bash.bug
Subject Unexpected delay in using arguments.
Date Sun, 12 Aug 2018 03:16:34 -0400
Lines 38
Approved bug-bash@gnu.org
Message-ID <mailman.5025.1534058199.1292.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1534058199 22252 208.118.235.17 (12 Aug 2018 07:16:39 GMT)
X-Complaints-To action@cs.stanford.edu
To Chet Ramey <chet.ramey@case.edu>, bug-bash <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=x3hOoVYc+LeLkfGOWkBsA4VRCdiZsgiyd/5lJpPagPs=; b=kxy3dyGc6Q+UwwHrtV9Sm6M4j3i+vyWBHC3RBL4d3WOwyjV20Vaua/Ygaxqn0B5bl3 lpz62Jsa6310SIloOkgvXVmR4pOaVGq2Hmqjz/t1NcoBdX0+avL/ubdhAzeO8ZbgWvvz 4/cRheSIK9zzqmRowxFxrmEsIETB4UtWHC1QXrxzbA1wutd85zJrjzsBf+pTKi7OffAz qwdAt/ZrRfLz2dqgwfZpCesDFeIicf6DPEhN3lrnBGeCh+ldS1P5K55twGWuBDxFl0wR +15sqDVp39RYXrpC5/8P2hsPrmSJcG7tuelS8piUwJFLdEKu+cGjpScrOYGcrXz5S3mV Ig1Q==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=x3hOoVYc+LeLkfGOWkBsA4VRCdiZsgiyd/5lJpPagPs=; b=Jn5ombmMWa2mzE0wHQda5x/Q5kmG6n5OIle5YzF4Ifv9IzpVX9/M1qpe5FLaEeR3rn cOcYMGj4yQcjuDDFC5azrAdTzfsBjF/AxWOfJGHE+cI3NQcXYrVPil58Pv8ZGqb7vZ5o qlF7ugRe0KS4PciVg8TfoTR78Hl6SQ6WDo+U8T5uAeB++q5Sx8EoArX20JSmo790EJZU 2eo6Ou7NJ25sExN9t43ne/uYy0LX4ryWGj1yqBMrgHEkFvx5+Q2sUAFnSwqLU+9TrP8N JmufkPTt9supKop9iwdovE+0ugtlBNad3KaXaqhhVGaeJHQeD5aYHbESIUTEj9xvbSG+ rl3Q==
X-Gm-Message-State AOUpUlEG4jwJssaFgtO3bp6WiVZBWlWvz4JPzbJ9YzC5v3sCTq2fGct1 MCBhtODOEAkXyuJRCGG95ZXVlcb3E9lBIqar0Ig=
X-Google-Smtp-Source AA+uWPwJ7TM0WugZ9KAVOTyIeJYKVrIyXww4U3C3Gl4YZ99fQtlVkkQK4xWxWtdsI0HrcgrBabpcKsqqnIVvCVrE9Ro=
X-Received by 2002:aca:3a03:: with SMTP id h3-v6mr12832931oia.270.1534058194843; Sun, 12 Aug 2018 00:16:34 -0700 (PDT)
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:4003:c06::233
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14467

Show key headers only | View raw


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


Thread

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

csiph-web