[Bug 249620] Re: dash does not support multi-digit file descriptors

Launchpad Bug Tracker 249620 at bugs.launchpad.net
Wed Jul 2 14:43:17 UTC 2014


Status changed to 'Confirmed' because the bug affects multiple users.

** Changed in: dash (Ubuntu)
       Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to dash in Ubuntu.
https://bugs.launchpad.net/bugs/249620

Title:
  dash does not support multi-digit file descriptors

Status in “dash” package in Ubuntu:
  Confirmed
Status in “dash” package in Debian:
  Confirmed

Bug description:
  Binary package hint: dash

  Found in dash version 0.5.4-8ubuntu1.

  The POSIX specification for "Shell Command Language" at
  http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_07
  says that multi-digit file descriptors are allowed, i.e. 10, 20, 25,
  etc..

  The relevant part of the specification is
  "The redirection operator:

  [n]>&word

  shall duplicate one output file descriptor from another, or shall
  close one. If word evaluates to one or more digits, the file
  descriptor denoted by n, or standard output if n is not specified,
  shall be made to be a copy of the file descriptor denoted by word ..."

  Dash seems to only support single digit fds:
  kstemen at kyle-vmserver:~$ sh 3>3.txt 9>9.txt 10>10.txt 11>11.txt
  $ ls /proc/$$/fd
  0  1  10  11  12  2  3  9
  $ echo test >&3
  $ echo test >&9
  $ echo test >&10
  sh: Syntax error: Bad fd number
  $ echo test >&11
  sh: Syntax error: Bad fd number
  $ 

  This seems to be caused by fixredir in parser.c:
  void fixredir(union node *n, const char *text, int err)
      {
      TRACE(("Fix redir %s %d\n", text, err));
      if (!err)
          n->ndup.vname = NULL;

      if (is_digit(text[0]) && text[1] == '\0')
          n->ndup.dupfd = digit_val(text[0]);
      else if (text[0] == '-' && text[1] == '\0')
          n->ndup.dupfd = -1;
      else {

          if (err)
              synerror("Bad fd number");
          else
              n->ndup.vname = makename();
      }
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/249620/+subscriptions



More information about the foundations-bugs mailing list