Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh PR/49125: Havard Eidnes: /bin/sh does not support red...



details:   https://anonhg.NetBSD.org/src/rev/4b0245824ad4
branches:  trunk
changeset: 801823:4b0245824ad4
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 19 12:36:58 2014 +0000

description:
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.

diffstat:

 bin/sh/parser.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (61 lines):

diff -r a76f944c9c74 -r 4b0245824ad4 bin/sh/parser.c
--- a/bin/sh/parser.c   Tue Aug 19 07:28:45 2014 +0000
+++ b/bin/sh/parser.c   Tue Aug 19 12:36:58 2014 +0000
@@ -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 @@
        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 @@
        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 @@
  */
 
 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 @@
                        break;
                }
        }
-       if (fd != '\0')
-               np->nfile.fd = digit_val(fd);
+       if (*fd != '\0')
+               np->nfile.fd = number(fd);
        redirnode = np;
        goto parseredir_return;
 }



Home | Main Index | Thread Index | Old Index