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 e4cb51356521 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue 
Sep 28 20:41:07 UTC 2021 x86_64 Linux
Machine Type: x86_64-pc-linux-musl

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

Description:
        When an ERR trap includes newlines, the line number returned by
        "caller 0" is affected.

Repeat-By:
        Here are some examples.

        $ cat -n 1.bash
             1  set -E -e
             2  f() { i=0; while caller $((i++)); do :; done; }
             3  trap 'f' ERR
             4  false
        $ bash 1.bash
        4 main 1.bash

        $ cat -n 2.bash
             1  set -E -e
             2  f() { i=0; while caller $((i++)); do :; done; }
             3  trap '
             4  f' ERR
             5  false
        $ bash 2.bash
        6 main 2.bash

        $ cat -n 3.bash
             1  set -E -e
             2  f() { i=0; while caller $((i++)); do :; done; }
             3  trap '
             4  
             5  f' ERR
             6  false
        $ bash 3.bash
        8 main 3.bash

        $ cat -n 4.bash
             1  set -E -e
             2  f() { i=0; while caller $((i++)); do :; done; }
             3  trap 'f' ERR
             4  g() { false; }
             5  g
        $ bash 4.bash
        4 g 4.bash
        5 main 4.bash

        $ cat -n 5.bash
             1  set -E -e
             2  f() { i=0; while caller $((i++)); do :; done; }
             3  trap '
             4  f' ERR
             5  g() { false; }
             6  g
        $ bash 5.bash
        6 g 5.bash
        6 main 5.bash

        $ cat -n 6.bash
             1  set -E -e
             2  f() { i=0; while caller $((i++)); do :; done; }
             3  trap '
             4  
             5  f' ERR
             6  g() { false; }
             7  g
        $ bash 6.bash
        8 g 6.bash
        7 main 6.bash

Reply via email to