Module Name: src Committed By: christos Date: Tue Aug 19 12:36:58 UTC 2014
Modified Files: src/bin/sh: parser.c Log Message: PR/49125: Havard Eidnes: /bin/sh does not support redirecting to or from FDs > 9 According to: http://pubs.opengroup.org/onlinepubs/009604599/utilities/xcu_chap02.html#tag_02_07 Redirection support for fds > 9 is optional but allowed. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/parser.c diff -u src/bin/sh/parser.c:1.90 src/bin/sh/parser.c:1.91 --- src/bin/sh/parser.c:1.90 Wed Jan 1 14:50:44 2014 +++ src/bin/sh/parser.c Tue Aug 19 08:36:58 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.90 2014/01/01 19:50:44 christos Exp $ */ +/* $NetBSD: parser.c,v 1.91 2014/08/19 12:36:58 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; #else -__RCSID("$NetBSD: parser.c,v 1.90 2014/01/01 19:50:44 christos Exp $"); +__RCSID("$NetBSD: parser.c,v 1.91 2014/08/19 12:36:58 christos Exp $"); #endif #endif /* not lint */ @@ -647,8 +647,8 @@ void fixredir(union node *n, const char if (!err) n->ndup.vname = NULL; - if (is_digit(text[0]) && text[1] == '\0') - n->ndup.dupfd = digit_val(text[0]); + if (is_number(text)) + n->ndup.dupfd = number(text); else if (text[0] == '-' && text[1] == '\0') n->ndup.dupfd = -1; else { @@ -1149,8 +1149,7 @@ endword: if (eofmark == NULL) { if ((c == '>' || c == '<') && quotef == 0 - && len <= 2 - && (*out == '\0' || is_digit(*out))) { + && (*out == '\0' || is_number(out))) { PARSEREDIR(); return lasttoken = TREDIR; } else { @@ -1208,8 +1207,9 @@ checkend: { */ parseredir: { - char fd = *out; + char fd[64]; union node *np; + strlcpy(fd, out, sizeof(fd)); np = (union node *)stalloc(sizeof (struct nfile)); if (c == '>') { @@ -1258,8 +1258,8 @@ parseredir: { break; } } - if (fd != '\0') - np->nfile.fd = digit_val(fd); + if (*fd != '\0') + np->nfile.fd = number(fd); redirnode = np; goto parseredir_return; }