From jonny@jonny.eng.br  Thu Aug  1 11:10:51 2002
Return-Path: <jonny@jonny.eng.br>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2634137B400
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  1 Aug 2002 11:10:51 -0700 (PDT)
Received: from coe.ufrj.br (roma.coe.ufrj.br [146.164.53.65])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1826743E42
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  1 Aug 2002 11:10:49 -0700 (PDT)
	(envelope-from jonny@jonny.eng.br)
Received: by coe.ufrj.br (Postfix, from userid 2000)
	id 374A0D9233; Thu,  1 Aug 2002 15:10:39 -0300 (BRT)
Message-Id: <20020801181039.374A0D9233@coe.ufrj.br>
Date: Thu,  1 Aug 2002 15:10:39 -0300 (BRT)
From: Joao Carlos Mendes Luis <jonny@jonny.eng.br>
Reply-To: Joao Carlos Mendes Luis <jonny@jonny.eng.br>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: /bin/sh builtins redirection failures abort entire script
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41240
>Category:       bin
>Synopsis:       /bin/sh builtins redirection failures abort entire script
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 01 11:20:01 PDT 2002
>Closed-Date:    Mon Aug 12 11:12:48 PDT 2002
>Last-Modified:  Mon Aug 12 11:12:48 PDT 2002
>Originator:     Joao Carlos Mendes Luis
>Release:        FreeBSD 4.6-STABLE i386
>Organization:
COPPE/UFRJ
>Environment:
System: FreeBSD roma.coe.ufrj.br 4.6-STABLE FreeBSD 4.6-STABLE #0: Tue Jul 9 16:08:41 BRT 2002 jonny@roma.coe.ufrj.br:/usr/cvsup/RELENG_4/src/sys/compile/ROMA i386

	4-stable from July, 29, 2002

>Description:

	See example below

>How-To-Repeat:

This script fails with /bin/sh, works with bash

#! /bin/sh

TestFunc()
{
  ${ECHO} "no perm" > $file
  #  Builtin echo does not reach here
  ${ECHO} ok
  ${ECHO} "no perm" >> $file
  ${ECHO} ok
}

file=/tmp/xxx
touch $file
chmod 000 $file

ECHO=/bin/echo
TestFunc
ECHO=echo
TestFunc

>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jon 
State-Changed-When: Mon Aug 12 11:08:42 PDT 2002 
State-Changed-Why:  
Contrary to popular belief, bash does not define the standard to unix shells... :) 

This behavior is consistant with the expected historical behavior of /bin/sh; csh and tcsh also behaves in a similar manner. 

If you want to ignore failures hen redirecting, you can put parenthesis around the command, like: (echo foo > /nonexistant/foo/bar) 


http://www.freebsd.org/cgi/query-pr.cgi?pr=41240 
>Unformatted:
