From owner-svn-src-head@FreeBSD.ORG Sun Oct 24 20:09:49 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F604106566C; Sun, 24 Oct 2010 20:09:49 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D5068FC20; Sun, 24 Oct 2010 20:09:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9OK9n0x038631; Sun, 24 Oct 2010 20:09:49 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9OK9nQ3038628; Sun, 24 Oct 2010 20:09:49 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201010242009.o9OK9nQ3038628@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 24 Oct 2010 20:09:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214290 - in head: bin/sh tools/regression/bin/sh/execution X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2010 20:09:49 -0000 Author: jilles Date: Sun Oct 24 20:09:49 2010 New Revision: 214290 URL: http://svn.freebsd.org/changeset/base/214290 Log: 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) Added: head/tools/regression/bin/sh/execution/redir4.0 (contents, props changed) Modified: head/bin/sh/redir.c Modified: head/bin/sh/redir.c ============================================================================== --- head/bin/sh/redir.c Sun Oct 24 19:56:34 2010 (r214289) +++ head/bin/sh/redir.c Sun Oct 24 20:09:49 2010 (r214290) @@ -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); } Added: head/tools/regression/bin/sh/execution/redir4.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/execution/redir4.0 Sun Oct 24 20:09:49 2010 (r214290) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +{ echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&- +exit 0