From owner-freebsd-bugs@FreeBSD.ORG Wed May 11 00:20:06 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D4FAC16A4CE for ; Wed, 11 May 2005 00:20:06 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF16343D45 for ; Wed, 11 May 2005 00:20:06 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j4B0K6uk039748 for ; Wed, 11 May 2005 00:20:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j4B0K6vR039747; Wed, 11 May 2005 00:20:06 GMT (envelope-from gnats) Date: Wed, 11 May 2005 00:20:06 GMT Message-Id: <200505110020.j4B0K6vR039747@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Subject: Re: bin/80868: /bin/sh gives wrong line number of unterminated quoted string error X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2005 00:20:06 -0000 The following reply was made to PR bin/80868; it has been noted by GNATS. From: Giorgos Keramidas To: Daniel Rudy 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 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 :-(