Date: Mon, 31 Jul 2006 15:07:01 +0400 (MSD) From: Yar Tikhiy <yar@comp.chem.msu.su> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/101094: sh(1) can show wrong line numbers in its diagnostic messages Message-ID: <200607311107.k6VB71HR072264@jujik.ramtel.ru> Resent-Message-ID: <200607311110.k6VBAGrw054478@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 101094
>Category: bin
>Synopsis: sh(1) can show wrong line numbers in its diagnostic messages
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 31 11:10:09 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Yar Tikhiy
>Release: FreeBSD 7.0-CURRENT i386
>Organization:
None
>Environment:
System: FreeBSD jujik.ramtel.ru 7.0-CURRENT FreeBSD 7.0-CURRENT #6: Tue Jun 27 14:45:05 MSD 2006 glebius@jujik.ramtel.ru:/usr/obj/usr/src/sys/JUJIK i386
>Description:
sh(1) tries to keep track of the number of the current line
in the current script file. The main use of this is in
diagnostic messages, such as "%s: %d: Syntax error ...",
which come very helpful when debugging complex scripts.
However, the line numbering is broken as soon as a line
continuation is encountered.
>How-To-Repeat:
Example 1:
%cat -b test.sh
1 foo="\
2 1\
3 2\
4 3\
5 "
6 esac
%sh -n test.sh
test.sh: 2: Syntax error: "esac" unexpected
Example 2:
%cat -b test2.sh
1 echo \
2 1\
3 2\
4 3\
5 4
6 esac
%sh -n test2.sh
test2.sh: 3: Syntax error: "esac" unexpected
In both cases, the error actually was in line 6.
On the other hand:
%cat -b test3.sh
1 echo \
2 1 \
3 2 \
4 3 \
5 4
6 esac
%sh -n test3.sh
test3.sh: 6: Syntax error: "esac" unexpected
In this case, the line number is correct. Perhaps the problem
appears when a single shell word is split across multiple lines.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607311107.k6VB71HR072264>
