Bug 41240

Summary: /bin/sh builtins redirection failures abort entire script
Product: Base System Reporter: jonny <jonny>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.6-STABLE   
Hardware: Any   
OS: Any   

Description jonny 2002-08-01 19:20:01 UTC
	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
Comment 1 Jonathan Chen freebsd_committer freebsd_triage 2002-08-12 19:08:42 UTC
State Changed
From-To: open->closed

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)