Home | History | Annotate | Download | only in sh
History log of /src/bin/sh/output.c
RevisionDateAuthorComments
 1.42  03-Oct-2024  rillig bin: fix lint warning "effectively discards 'const'"

For example: src/bin/ed/io.c(339): warning: call to 'strchr' effectively
discards 'const' from argument [346]

No binary change.
 1.41  07-Apr-2023  kre The great shell trailing whitespace cleanup of 2023...
Inspired by private e-mail comments from mouse@

NFCI.
 1.40  21-Nov-2017  kre branches: 1.40.4;
Remove the -X option from SMALL shells (as used on boot floppies,
some other install media, mini-roots, etc.) It is unlikely that
such a shell will be used for much script debugging (and the old -x
still exists of course) and it adds a little bloat, so, zap...

The ancient unused (unrelated) xioctl() function is gone as well
(from all shells).
 1.39  19-Nov-2017  kre Implement the -X option - an apparent variant of -x which sends all trace
output to the stderr which existed when the -X option was (last) enabled.
It also enables tracing by enabling -x (and when reset, +X, also resets
the 'x' flag (+x)). Note that it is still -x/+x which actually
enables/disables the trace output. Hence "apparent variant" - what -X
actually does (aside from setting -x) is just to lock the trace output,
rather than having it follow wherever stderr is later redirected.
 1.38  19-Nov-2017  kre Rearrange "struct output" to be slightly more friendly (I think)
to I32 P64 systems - keep nextc first, as that's used in macros,
and nleft next, as that's used (and both are updated) in the same macro,
which is used frequently, this increases the chance they're in the
same cache line (unchanged from before). Beyond that it matters less,
so just shuffle a bit to avoid internal padding when pointers are 64 bits.
Note that there are just 3 of these structs (currently), even if there was
to be a memory saving (there probably won't be, trailing padding will eat it)
it would be of the order of 12 or 24 bytes total, so all this really
just panders to my sense of rightness....

Note to anyone who might be tempted, please don't update the struct
initializers to use newer C forms - eventually sh is planned to become
a host tool, and a separable package, so it wants to remain able to be
compiled using older (though at least ansi) compilers that implement only
older C variants.
 1.37  16-Nov-2017  kre Improve quoting in xtrace (-x) output ... if a string ("word") to be
output includes a single quote (') then see if using double-quotes
to quote it is reasonable (if no chars that are magic in " also appear).
If so, and if the string is not entirely the ' character, then
use " quoting. This avoids some ugly looking results (occasionally).

Also, fix a bug introduced about 20 months ago where null strings
in xtrace output are dropped, instead of made explicit ('').
To observe this, before you get the fix: set -x; echo '' (or similar.)

Move a comment from the wrong place to the right place.
 1.36  18-May-2017  kre branches: 1.36.2;

Added comma and plus to the "don't need quoting" set. This affects
output from "sh -x" only (tracing execution), not quoting + is better,
as it makes tracing commands with + and - options, or numbers, more
consistent.

Also one minor white space change (excess indentation removed).
 1.35  12-Mar-2016  christos branches: 1.35.6;
Improve quoting in the output from sh -x - use less unnecessary
quotes ('_' and '.' do not need quoting) and never quote the '=' in
an assignment (or it would not be one.) From kre, with some refactoring
to be blamed to me.
 1.34  28-Feb-2016  christos Bug fixes to handling of unterminated here documents
(they should be, and now are, a syntax error), and
miscellaneous other minor cleanups. (from kre)
 1.33  30-Aug-2010  christos dprintf is claimed by posix.
 1.32  19-Jul-2010  joerg Don't quite `+', `-' and `/' in set -x output.
 1.31  31-Oct-2008  christos show better quoting output for sh -x, from Aleksey Cheusov
 1.30  12-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.29  17-Mar-2006  rumble branches: 1.29.4;
Handle asprintf failing to allocate.
 1.28  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.27  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.26  25-May-2002  wiz __STDC__ is always defined on NetBSD, so remove #ifdef __STDC__ (and
unnecessary #else cases).
 1.25  09-Apr-2002  thorpej Move the declaration of digit[] into the #ifdef'd code block that
uses it. Prevents a warning from gcc 3.2.
 1.24  24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.23  07-Jan-2001  lukem if HAVE_VASPRINTF (set ifdef BSD4_4), use vasprintf() instead of homegrown
code in doformat(). results in slightly smaller /bin/sh. idea suggested by
Witold J. Wnuk <witek@pd37.warszawa.sdi.tpnet.pl>, approved by christos.
 1.22  07-Jan-2001  lukem support %ll (as synonym for %q) in doformat(), since my changes to %q -> %ll
broke this :/
problem reported in private email by Witold J. Wnuk.
<witek@pd37.warszawa.sdi.tpnet.pl>.
 1.21  31-Jan-1998  christos - Add gcc attributes to printf like functions
- Fix format strings to be const
- Fix buffer length to be size_t
- Add %p format
- Avoid code duplication in varargs/stdarg cases
 1.20  21-Jan-1998  christos BSD4_4 is a standard symbol in <sys/param.h>; make sure that files
that need this defined, include <sys/param.h> and don't define it in
the Makefile. Add a comment to that effect.
 1.19  04-Jul-1997  christos branches: 1.19.2;
Fix compiler warnings.
 1.18  11-Apr-1997  christos Fix so that this compiles on systems without quads and remove the double
inclusion of varargs/stdarg
 1.17  11-Jan-1997  tls kill 'register'
 1.16  16-Oct-1996  christos No need to have 2 declarations for the same constant string, one for K&R and
one for STDC...
 1.15  14-Sep-1995  jtc branches: 1.15.6;
Handle %q format directive; from Mike Long (PR #1454).
 1.14  11-May-1995  christos Merge in my changes from vangogh, and fix the x=`false`; echo $? == 0
bug.
 1.13  21-Mar-1995  cgd convert to new RCS id conventions.
 1.12  23-Dec-1994  cgd pull prototypes into scope for string functions.
 1.11  05-Dec-1994  cgd clean up further. more patches from Jim Jegers
 1.10  11-Jun-1994  mycroft Add RCS ids.
 1.9  12-May-1994  jtc Include appropriate header files to bring function prototypes into scope.
 1.8  12-May-1994  jtc add const qualifier to get rid of compilation warnings.
 1.7  11-May-1994  jtc sync with 4.4lite
 1.6  04-May-1994  jtc Added const qualifier to char * function arguments to eliminate
compiler warning.
 1.5  05-Sep-1993  mycroft From Vincent Broman:
error.c: Add , in initializer list if ENOLINK defined.
output.c: Gratuitously remove extra ;.
mknodes.c: main() should return a value.
Not from Vincent Broman:
mknodes.c: main() should return an error condition when approriate, too.
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 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.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.15.6.1  26-Jan-1997  rat Update /bin/sh from trunk per request of Christos Zoulas. Fixes
many bugs.
 1.19.2.1  08-May-1998  mycroft Sync with trunk, per request of christos.
 1.29.4.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.
 1.35.6.1  19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.36.2.1  23-Nov-2017  martin Pull up following revision(s) (requested by kre in ticket #384):
bin/sh/output.c: revision 1.37
Improve quoting in xtrace (-x) output ... if a string ("word") to be
output includes a single quote (') then see if using double-quotes
to quote it is reasonable (if no chars that are magic in " also appear).
If so, and if the string is not entirely the ' character, then
use " quoting. This avoids some ugly looking results (occasionally).
Also, fix a bug introduced about 20 months ago where null strings
in xtrace output are dropped, instead of made explicit ('').
To observe this, before you get the fix: set -x; echo '' (or similar.)
Move a comment from the wrong place to the right place.
 1.40.4.2  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.40.4.1  21-Apr-2020  martin Sync with HEAD

RSS XML Feed