bin/88845: Sh(1) aborts if builtin echo redirection fails

Ed Maste emaste at FreeBSD.org
Fri Nov 11 07:00:27 PST 2005


>Number:         88845
>Category:       bin
>Synopsis:       Sh(1) aborts if builtin echo redirection fails
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 11 15:00:25 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Ed Maste
>Release:        7.0-CURRENT
>Organization:
>Environment:
>Description:
A failed redirection of builtin echo from sh(1) causes sh to abort after printing the error message.  I would expect the script below to output "done" but it does not.
>How-To-Repeat:
Run this script:

#!/bin/sh
touch /tmp/foo
chmod 000 /tmp/foo
echo > /tmp/foo
echo done

>Fix:
This patch works around the problem but a better fix is needed to be POSIX compliant I'm told.

--- eval.c.orig Tue Apr  6 19:06:51 2004
+++ eval.c      Wed Nov  9 08:40:56 2005
@@ -807,7 +807,6 @@
                        memout.bufsize = 64;
                        mode |= REDIR_BACKQ;
                }
-               redirect(cmd->ncmd.redirect, mode);
                savecmdname = commandname;
                cmdenviron = varlist.list;
                e = -1;
@@ -818,6 +817,7 @@
                }
                savehandler = handler;
                handler = &jmploc;
+               redirect(cmd->ncmd.redirect, mode);
                commandname = argv[0];
                argptr = argv + 1;
                optptr = NULL;                  /* initialize nextopt */

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list