sh: Check whether dup2 was successful for >&FD and <&FD.
A failure (usually caused by FD not being open) is a redirection error. Exp-run done by: pav (with some other sh(1) changes)
This commit is contained in:
parent
7aaae32724
commit
3dec7d0c15
@ -217,8 +217,11 @@ movefd:
|
||||
if (redir->ndup.dupfd >= 0) { /* if not ">&-" */
|
||||
if (memory[redir->ndup.dupfd])
|
||||
memory[fd] = 1;
|
||||
else
|
||||
dup2(redir->ndup.dupfd, fd);
|
||||
else {
|
||||
if (dup2(redir->ndup.dupfd, fd) < 0)
|
||||
error("%d: %s", redir->ndup.dupfd,
|
||||
strerror(errno));
|
||||
}
|
||||
} else {
|
||||
close(fd);
|
||||
}
|
||||
|
4
tools/regression/bin/sh/execution/redir4.0
Normal file
4
tools/regression/bin/sh/execution/redir4.0
Normal file
@ -0,0 +1,4 @@
|
||||
# $FreeBSD$
|
||||
|
||||
{ echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&-
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user