Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 May 2005 00:20:06 GMT
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/80868: /bin/sh gives wrong line number of unterminated quoted string error
Message-ID:  <200505110020.j4B0K6vR039747@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/80868; it has been noted by GNATS.

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 :-(
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505110020.j4B0K6vR039747>