[Bug 268156] /bin/sh: errors are printed with wrong line numbers in strict mode (set -euo pipefail)

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 04 Dec 2022 22:29:37 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268156

            Bug ID: 268156
           Summary: /bin/sh: errors are printed with wrong line numbers in
                    strict mode (set -euo pipefail)
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: yuri@freebsd.org

This script:
> #!/bin/sh
> 
> set -euo pipefail # strict mode
> 
> echo "$1"

fails with:
> ./x.sh: 1: parameter not set

The actual error is in line 5, not line 1.

As a comparison, bash prints a correct line number:
> ./x.sh: line 5: $1: unbound variable

Bash error message is also more relevant.

-- 
You are receiving this mail because:
You are the assignee for the bug.