bin/137659: sh(1): /bin/sh fails to redirect stderr in backticks

Yar Tikhiy yar at
Tue Aug 11 07:30:10 UTC 2009

>Number:         137659
>Category:       bin
>Synopsis:       sh(1): /bin/sh fails to redirect stderr in backticks
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 11 07:30:09 UTC 2009
>Originator:     Yar Tikhiy
>Release:        FreeBSD 8.0-BETA2 amd64
System: FreeBSD 8.0-BETA2 FreeBSD 8.0-BETA2 #11 r195838: Fri Jul 24 09:52:42 UTC 2009 simon at amd64

	If the command to run in backticks has no path and the shell
	fails to run it, the stderr message cannot be redirected.

	For comparison, bash redirects OK in both cases.

Compare the following two cases.  In case 1, the "not found" message
is properly redirected to stdout and assigned to a variable while in
case 2 it's just emitted immediately, defying redirection.

$ out=`/var/empty/foo 2>&1`
$ echo $out
/var/empty/foo: not found
$ out=`nosuchtool 2>&1`
nosuchtool: not found
$ echo $out



More information about the freebsd-bugs mailing list