NetBSD/bin
kre e177ba5371 Fix a bug in the built-in echo in /bin/sh reported in private mail by
Oguz <oguzismailuysal@gmail.com>

If echo detects an I/O error, it does exit(1) (that's fine) but then
the next echo also does exit(1) even without any errors of its own,
and every following echo writing to stdout does the same thing.

eg:

echo foo >&- ; echo $?; echo $?; ( echo $( echo $?; echo $?) ; echo $? )
1
1
1 1
1

The first echo writes nothing (stdout is closed) but does exit(1).
The second echo writes "1" (correct, the exit status of the previous
echo) and should exit(0) - but doesn't.  This pattern continues...

While here, conform to the POSIX requirement on echo (and many other
standard utilities, but definitely not all) that when the utility
does exit(>0) a message must be written to stderr (and vice versa
in many cases).   Our echo (as shown above) did the exit(1) part
when it detected the I/O error, but no message is sent to stderr.
Fix that while we're here.

Similar changes are required for /bin/echo (coming soon), and
/usr/bin/printf (which is also the sh builtin printf) - except
currently that one kind of conforms, as it ignores errors writing
to stdout (as do large numbers of other utilities).  For many
programs that's kind of acceptable, but where the sole purpose of
the program is to write to stdout, it really isn't.   Also to be
fixed soon.
2021-05-18 21:39:06 +00:00
..
cat
chio typo: unvalid -> invalid 2017-10-16 17:08:35 +00:00
chmod
cp
csh
date
dd dd.1: add an example of writing a NetBSD image 2021-05-18 07:17:09 +00:00
df
domainname
echo
ed
expr
getfacl
hostname
kill
ksh PR/56007: Greg A. Woods: ksh unable to execute ERR traps 2021-02-23 01:31:30 +00:00
ln
ls Fix skipping of directories that begin with a '.' in -R mode. 2020-07-07 14:29:06 +00:00
mkdir
mt
mv
pax
ps Remove SCCS workaround. No binary change. 2021-04-17 08:35:33 +00:00
pwd
rcmd
rcp
rm
rmdir
setfacl
sh Fix a bug in the built-in echo in /bin/sh reported in private mail by 2021-05-18 21:39:06 +00:00
sleep
stty
sync
test
Makefile
Makefile.inc