bin/80868: /bin/sh gives wrong line number of unterminated
quoted string error
Giorgos Keramidas
keramida at freebsd.org
Wed May 11 00:20:06 GMT 2005
The following reply was made to PR bin/80868; it has been noted by GNATS.
From: Giorgos Keramidas <keramida at freebsd.org>
To: Daniel Rudy <dr2867.business at pacbell.net>
Cc: bug-followup at 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 at 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 :-(
More information about the freebsd-bugs
mailing list