Date: Tue, 03 Oct 2023 21:34:28 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 274254] The /bin/sh $LINENO value just after a nested function is misleading. Message-ID: <bug-274254-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D274254 Bug ID: 274254 Summary: The /bin/sh $LINENO value just after a nested function is misleading. Product: Base System Version: 13.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: white-pack@pm.me Created attachment 245417 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D245417&action= =3Dedit A sample script for inspiring a fix. The following script reveals the issue 1 #!/bin/sh 2 3 check() 4 { 5 echo $1 - \ 6 $( 7 [ $2 -eq $3 ] \ 8 && echo OK \ 9 || echo FAIL "($2 !=3D $3)" 10 ) 11 } 12 13 main() 14 { 15 check 2 $LINENO 3 16 17 inner() 18 { 19 check 4 $LINENO 3 20 } 21 22 check 3 $LINENO 10 23 inner 24 } 25 26 check 1 $LINENO 26 27 main Here's its output: 1 - OK 2 - OK 3 - FAIL (22 !=3D 10) 4 - OK Every line of the output should be "OK", but the third one fails. The internal logic controlling LINENO seems to ignore that inner() was nest= ed. I attach an ad-hoc "work-around" which could inspire a possible fix. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-274254-227>