bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extra timing statistics for failing function calls when errexit is enabl


From: Sergej Alikov
Subject: Extra timing statistics for failing function calls when errexit is enabled
Date: Mon, 13 Sep 2021 21:32:55 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-musl
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux ca533b27a98e 5.13.7-200.fc34.x86_64 #1 SMP Sat Jul 31 14:10:16 UTC 2021 x86_64 Linux
Machine Type: x86_64-pc-linux-musl

Bash Version: 5.1
Patch Level: 8
Release Status: release

Description:
        When the "time" keyword is used in a pipeline with
        function calls, and errexit is enabled - each failing
        function call will emit the timing statistics before the
        final statistics for the whole pipeline.

        I was able to reproduce this issue starting
        with Bash 4.4 - 5.1.8, both on Linux (glibc and musl) and MacOS.

Repeat-By:
        The following command reproduces the issue:

        bash-5.1# bash -ec 'foo () { false; }; time foo | foo'

        real    0m0.000s
        user    0m0.000s
        sys     0m0.000s

        real    0m0.001s
        user    0m0.000s
        sys     0m0.000s

        real    0m0.002s
        user    0m0.000s
        sys     0m0.002s

        The first two blocks are output by the foo() calls
        in the pipeline, and the third one is for
        the whole pipeline.
        Note the timings differ.

        I've run the command in a container to test it on the latest
        Bash version, but I get same results on the slighly older
        version on the host too.

        Oddly enough, the issue does not occur with a non-zero return:

        bash-5.1# bash -ec 'foo () { return 1; }; time foo | foo'

        real    0m0.001s
        user    0m0.001s
        sys     0m0.001s

        Also does not happen with normal commands:

        bash-5.1# bash -ec 'time false | false'

        real    0m0.002s
        user    0m0.001s
        sys     0m0.001s

        Also does not happen with functions which return zero exit code:

        bash-5.1# bash -ec 'foo () { true; }; time foo | foo'

        real    0m0.001s
        user    0m0.000s
        sys     0m0.001s



reply via email to

[Prev in Thread] Current Thread [Next in Thread]