summaryrefslogtreecommitdiffstats
path: root/bin/sh/parser.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-09-10 01:24:11 +0000
committerpeter <peter@FreeBSD.org>1996-09-10 01:24:11 +0000
commitaae29b5fef43167b0ab23b5350b23a6312867900 (patch)
tree34149b17c1927c43b2dd2f20f5d9a5cf6cdd4c56 /bin/sh/parser.c
parentc5a6fcbc6ced2de2faae882dbb27a2694688937b (diff)
downloadFreeBSD-src-aae29b5fef43167b0ab23b5350b23a6312867900.zip
FreeBSD-src-aae29b5fef43167b0ab23b5350b23a6312867900.tar.gz
Fix for PR#1248, sh doesn't expand past ${9}
Submitted by: Steve Price <sprice@hiwaay.net>
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r--bin/sh/parser.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index d24508e..1ffa2c3 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: parser.c,v 1.12 1996/09/01 10:21:31 peter Exp $
+ * $Id: parser.c,v 1.13 1996/09/03 14:15:57 peter Exp $
*/
#ifndef lint
@@ -1141,6 +1141,7 @@ parsesub: {
#ifndef GDB_HACK
static const char types[] = "}-+?=";
#endif
+ int bracketed_name = 0; /* used to handle ${[0-9]*} variables */
c = pgetc();
if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) {
@@ -1159,6 +1160,7 @@ parsesub: {
USTPUTC(VSNORMAL, out);
subtype = VSNORMAL;
if (c == '{') {
+ bracketed_name = 1;
c = pgetc();
if (c == '#') {
if ((c = pgetc()) == '}')
@@ -1174,6 +1176,16 @@ parsesub: {
STPUTC(c, out);
c = pgetc();
} while (is_in_name(c));
+ } else if (is_digit(c)) {
+ if (bracketed_name) {
+ do {
+ STPUTC(c, out);
+ c = pgetc();
+ } while (is_digit(c));
+ } else {
+ STPUTC(c, out);
+ c = pgetc();
+ }
} else {
if (! is_special(c))
badsub: synerror("Bad substitution");
OpenPOWER on IntegriCloud