From owner-freebsd-bugs Sun Aug 1 11: 0:18 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id E482814BDC for ; Sun, 1 Aug 1999 11:00:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id LAA47664; Sun, 1 Aug 1999 11:00:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Sun, 1 Aug 1999 11:00:02 -0700 (PDT) Message-Id: <199908011800.LAA47664@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Danny J. Zerkel" Subject: Re: bin/12137: something wrong with shell -- functions with arithm expressions Reply-To: "Danny J. Zerkel" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/12137; it has been noted by GNATS. From: "Danny J. Zerkel" To: freebsd-gnats-submit@freebsd.org, mi@aldan.algebra.com Cc: Subject: Re: bin/12137: something wrong with shell -- functions with arithm expressions Date: Sun, 01 Aug 1999 13:51:38 -0400 Mikhail, Well the addition is not required, nor does it have to be a function. This problem occurs when taking the length of an numbered argument value inside an algorithmic expression. So this displays the same error: set -- "abc (def [xyz])" echo $((${#1})) The problem appears to be that the argument variable is being parsed for special characters, which result in an extra character for every character in the set: !*?[=~:/- This parsing should not occur if we are going to take the length of the resulting string. Try this to see it: set -- "!*?[=~:/-" echo $((${#1})) 18! This patch should fix only this problem, without any side effects: --- /usr/src/bin/sh/parser.c.orig Sun Sep 13 15:24:57 1998 +++ /usr/src/bin/sh/parser.c Sun Aug 1 13:37:33 1999 @@ -1239,7 +1239,7 @@ } else { pungetc(); } - if (dblquote || arinest) + if (subtype != VSLENGTH && (dblquote || arinest)) flags |= VSQUOTE; *(stackblock() + typeloc) = subtype | flags; if (subtype != VSNORMAL) -- Danny J. Zerkel dzerkel@columbus.rr.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message