#
1.15 |
|
18-May-2021 |
kre |
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.
|
Revision tags: netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 netbsd-5-2-RELEASE netbsd-5-2-RC1 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
|
#
1.14 |
|
12-Oct-2008 |
dholland |
branches: 1.14.62; output.c output.h: expose OUTPUT_ERR (flag for an exposed flags variable) bltin.h: support ferror() echo.c: use ferror() to fail on output write errors
Another piece of PR bin/39574.
|
Revision tags: mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-base hpcarm-cleanup-base
|
#
1.13 |
|
12-Dec-2007 |
lukem |
use __RCSID()
|
Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-4-base netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
|
#
1.12 |
|
06-Feb-2005 |
perry |
branches: 1.12.10; 1.12.16; remove obsolete register declarations
|
Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
|
#
1.11 |
|
07-Aug-2003 |
agc |
Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
|
#
1.10 |
|
04-Jan-2003 |
wiz |
Spell output with two ts.
|
Revision tags: fvdl_fs64_base
|
#
1.9 |
|
24-Nov-2002 |
christos |
Fixes from David Laight: - ansification - format of output of jobs command (etc) - job identiers %+, %- etc - $? and $(...) - correct quoting of output of set, export -p and readonly -p - differentiation between nornal and 'posix special' builtins - correct behaviour (posix) for errors on builtins and special builtins - builtin printf and kill - set -o debug (if compiled with DEBUG) - cd src obj (as ksh - too useful to do without) - unset -e name, remove non-readonly variable from export list. (so I could unset -e PS1 before running the test shell...)
|
Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base netbsd-1-5-PATCH003 ELRICshvfork-base netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
|
#
1.8 |
|
02-Nov-1996 |
christos |
Fix problems that gcc -Wall found (from Todd Miller, OpenBSD)
|
Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
|
#
1.7 |
|
21-Mar-1995 |
cgd |
branches: 1.7.6; convert to new RCS id conventions.
|
Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
|
#
1.6 |
|
11-Jun-1994 |
mycroft |
Add RCS ids.
|
#
1.5 |
|
11-May-1994 |
jtc |
sync with 4.4lite
|
#
1.4 |
|
01-Aug-1993 |
mycroft |
Add RCS identifiers.
|
Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
|
#
1.3 |
|
23-Mar-1993 |
cgd |
changed "Id" to "Header" for rcsids
|
#
1.2 |
|
22-Mar-1993 |
cgd |
added rcs ids to all files
|
#
1.1 |
|
21-Mar-1993 |
cgd |
branches: 1.1.1; Initial revision
|
#
1.14 |
|
11-Oct-2008 |
dholland |
output.c output.h: expose OUTPUT_ERR (flag for an exposed flags variable) bltin.h: support ferror() echo.c: use ferror() to fail on output write errors
Another piece of PR bin/39574.
|
#
1.13 |
|
12-Dec-2007 |
lukem |
use __RCSID()
|
#
1.12 |
|
05-Feb-2005 |
perry |
branches: 1.12.10; 1.12.16; remove obsolete register declarations
|
#
1.11 |
|
07-Aug-2003 |
agc |
Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
|
#
1.10 |
|
04-Jan-2003 |
wiz |
Spell output with two ts.
|
#
1.9 |
|
24-Nov-2002 |
christos |
Fixes from David Laight: - ansification - format of output of jobs command (etc) - job identiers %+, %- etc - $? and $(...) - correct quoting of output of set, export -p and readonly -p - differentiation between nornal and 'posix special' builtins - correct behaviour (posix) for errors on builtins and special builtins - builtin printf and kill - set -o debug (if compiled with DEBUG) - cd src obj (as ksh - too useful to do without) - unset -e name, remove non-readonly variable from export list. (so I could unset -e PS1 before running the test shell...)
|
#
1.8 |
|
02-Nov-1996 |
christos |
Fix problems that gcc -Wall found (from Todd Miller, OpenBSD)
|
#
1.7 |
|
21-Mar-1995 |
cgd |
branches: 1.7.6; convert to new RCS id conventions.
|
#
1.6 |
|
10-Jun-1994 |
mycroft |
Add RCS ids.
|
#
1.5 |
|
11-May-1994 |
jtc |
sync with 4.4lite
|
#
1.4 |
|
01-Aug-1993 |
mycroft |
Add RCS identifiers.
|
#
1.3 |
|
22-Mar-1993 |
cgd |
changed "Id" to "Header" for rcsids
|
#
1.2 |
|
22-Mar-1993 |
cgd |
added rcs ids to all files
|
#
1.1 |
|
21-Mar-1993 |
cgd |
branches: 1.1.1; Initial revision
|
#
1.1.1.2 |
|
11-May-1994 |
jtc |
44lite code
|
#
1.1.1.1 |
|
21-Mar-1993 |
cgd |
initial import of 386bsd-0.1 sources
|
#
1.7.6.1 |
|
25-Jan-1997 |
rat |
Update /bin/sh from trunk per request of Christos Zoulas. Fixes many bugs.
|
#
1.12.16.1 |
|
08-Jan-2008 |
matt |
sync with HEAD
|
#
1.12.10.1 |
|
18-Nov-2008 |
bouyer |
Pull up following revision(s) (requested by dholland in ticket #1232): bin/echo/echo.c: revision 1.18 bin/sh/bltin/bltin.h: revision 1.13 bin/sh/bltin/echo.c: revision 1.14 bin/sh/output.c: revision 1.30 bin/sh/output.h: revision 1.19 Check ferror(stdout) and exit(1) if there's been a problem. Fixes PR bin/39574 from Ed Ravin, but with a simpler patch. output.c output.h: expose OUTPUT_ERR (flag for an exposed flags variable) bltin.h: support ferror() echo.c: use ferror() to fail on output write errors Another piece of PR bin/39574.
|