From nobody@FreeBSD.org  Tue May 10 20:35:59 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6771416A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 May 2005 20:35:59 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 51C5943DA2
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 May 2005 20:35:59 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j4AKZxPd019349
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 May 2005 20:35:59 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j4AKZxwU019348;
	Tue, 10 May 2005 20:35:59 GMT
	(envelope-from nobody)
Message-Id: <200505102035.j4AKZxwU019348@www.freebsd.org>
Date: Tue, 10 May 2005 20:35:59 GMT
From: Daniel Rudy <dr2867.business@pacbell.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /bin/sh gives wrong line number of unterminated quoted string error
X-Send-Pr-Version: www-2.3

>Number:         80868
>Category:       bin
>Synopsis:       sh(1) gives wrong line number of unterminated quoted string error
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 10 20:40:01 GMT 2005
>Closed-Date:    Sat May 15 15:50:47 UTC 2010
>Last-Modified:  Sat May 15 15:50:47 UTC 2010
>Originator:     Daniel Rudy
>Release:        5.3-RELEASE-p6
>Organization:
>Environment:
FreeBSD wildfire.danielrudy.org 5.3-RELEASE-p6 FreeBSD 5.3-RELEASE-p6 #2: Wed Mar 30 06:30:41 PST 2005     root@strata:/usr/obj/usr/src/sys/WILDFIRE  i386
>Description:
When using borne shell scripts (/bin/sh) and there is a coding error in the script which results in a unterminated quoted string, /bin/sh gives the wrong line number of the error.
>How-To-Repeat:
Consider the following script:

unquote:
#!/bin/sh

echo "quote 1"
echo "quote 2
echo "quote 3"
echo "quote 4"

will yeild the following output:
./unquote: 6: Syntax error: Unterminated quoted string

It should be indicating that the error is on line 4, not line 6.  This causes a real hassle to find a unquoted terminated string if you have a large script with many strings.


>Fix:
Unknown.
>Release-Note:
>Audit-Trail:

From: Giorgos Keramidas <keramida@freebsd.org>
To: Daniel Rudy <dr2867.business@pacbell.net>
Cc: bug-followup@freebsd.org
Subject: Re: bin/80868: /bin/sh gives wrong line number of unterminated quoted string error
Date: Wed, 11 May 2005 03:13:37 +0300

 On 2005-05-10 20:35, Daniel Rudy <dr2867.business@pacbell.net> wrote:
 > Consider the following script:
 >
 > unquote:
 > #!/bin/sh
 >
 > echo "quote 1"
 > echo "quote 2
 > echo "quote 3"
 > echo "quote 4"
 >
 > will yeild the following output:
 > ./unquote: 6: Syntax error: Unterminated quoted string
 
 This is probably because sh tries to join lines when it finds a missing
 quote.  See, i.e. the output of:
 
     $ cat << EOF | sh
     > echo "hello world
     > hello second world"
     > EOF
     hello world
     hello second world
     $
 
 > It should be indicating that the error is on line 4, not line 6.  This
 > causes a real hassle to find a unquoted terminated string if you have
 > a large script with many strings.
 
 By trying to read the next line, when sh(1) finds an unterminated quote,
 may be lead many lines further below, matching quotes in pairs until it
 either hits an invalid command or until it hits EOF and discovers that
 there is _still_ a quote missing.
 
 I don't think there is an easy way to fix this without breaking the
 support of sh(1) for continuing quoted material following lines :-(
 
State-Changed-From-To: open->closed 
State-Changed-By: jilles 
State-Changed-When: Sat May 15 15:46:53 UTC 2010 
State-Changed-Why:  
This cannot be fixed without breaking the (required) support for having 
newlines within quotes. 

Some helpful tools: vim syntax highlighting (but be careful because it 
has a few bugs), sh's -x option. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=80868 
>Unformatted:
