Re: output redirections

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

 



On 1/14/08, Lucas Nussbaum <lucas@xxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> I rebuilt all packages in Debian in a chroot using dash as /bin/sh,
> which uncovered quite a lot of problems in build scripts.
> One of the problems is about output redirection.
>
> I understand that:
>   command &>/dev/null
> is a bashism. (with dash, it forks a subshell)
>
> the "common" replacement is:
>   command >/dev/null 2>&1
> Which works fine with dash. However, I couldn't find any reference to
> ">&1" in the posix standard. Is it really posix-compliant? Shouldn't we
> use instead:
>    command >/dev/null 2>/dev/null

|2.7.6 Duplicating an Output File Descriptor
|...If word evaluates to one or more digits, the file descriptor
denoted by n,...

http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_07_06

It's a very usual practice, btw. But on large scale it's not too flexible
and very feature-limited. It would be even less flexible, if two file names
were a must to specify. It's generally one more (quite heavy) open() syscall.
Check this.

strace /bin/dash -c 'echo >/dev/null 2>/dev/null'
strace /bin/dash -c 'echo >/dev/null 2>&1'

-- 
-o--=O`C
  #oo'L O
<___=E M
-
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux