History log of /freebsd-current/bin/sh/output.c
Revision Date Author Comments
# e043f372 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 90aea514 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 94b793c4 19-Feb-2019 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Send normal output from bind builtin to stdout

PR: 233343
Submitted by: Yuichiro NAITO (original version)


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 29717eb0 18-May-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Keep output buffer across builtins.

Allocating and deallocating repeatedly the 1024-byte buffer for stdout from
builtins costs CPU time for little or no benefit.

A simple loop containing builtins that write to a file descriptor, such as
i=0; while [ "$i" -lt 1000000 ]; do printf .; i=$((i+1)); done >/dev/null
is over 10% faster in a simple benchmark on an amd64 virtual machine.


# de29cd08 18-May-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Ensure memout.bufsize matches allocated buffer, if it exists.


# 5183ddf2 16-May-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Simplify output buffering.

Similarly to how STPUTC was changed, change struct output to store the
pointer just past the end of the available space instead of the size of the
available space, so after writing a character it is only necessary to
increment a pointer and not to decrement a counter.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 88ef06f3 14-Dec-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Make sure output suitable as shell input is also printable.

Commands like 'export -p', 'set' and 'trap', and tracing enabled via 'set
-x' generate output suitable as shell input by adding quotes as necessary.

If there are control characters other than newline or invalid UTF-8
sequences, use $'...' and \OOO to display them safely.

The resulting output is not parsable by a strict POSIX.1-2008 shell but sh
from FreeBSD 9.0 and newer and many other shells can parse it.


# e753a1ef 30-Nov-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Remove special case for '=' in set -x; always quote it in outqstr().

I plan to make set -x output always printable using $'...'; avoiding quoting
words containing '=' is not worth the extra complexity.


# f8533659 25-Jul-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Remove output.c's reset() handler.

These cleanup operations are not needed because they are already performed
after an optimized command substitution (whether there was an error or not).


# d6d66cfc 12-Dec-2012 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Detect and flag write errors on stdout in builtins.

If there is a write error on stdout, a message will be printed (to stderr)
and the exit status will be changed to 2 if it would have been 0 or 1.

PR: bin/158206


# 6903c683 11-Dec-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Use vsnprintf() rather than crafting our own in fmtstr().
Add INTOFF/INTON as longjmp out of vsnprintf may cause memory leaks or
undefined behaviour.


# aeb5d065 20-Nov-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Code size optimizations to buffered output.

This is mainly less use of the outc macro.

No functional change is intended, but code size is about 2K less on i386.


# c3f57269 14-Nov-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add binary buffered output for use by the printf builtin.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 88328642 13-Oct-2010 David E. O'Brien <obrien@FreeBSD.org>

In the spirit of r90111, depend on c89 and remove the "STATIC" macro
and its usage.


# aa7b6f82 12-Oct-2010 David E. O'Brien <obrien@FreeBSD.org>

Consistently use "STATIC" for all functions in order to be able to set
breakpoints with in a debugger. And use naked "static" for variables.

Noticed by: bde


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 2cac6e36 24-Dec-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Constify various strings.

Most of this is adding const keywords, but setvar() in var.c had to be
changed somewhat more.


# c6204d4a 21-Nov-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Some changes to stderr flushing:
* increase buffer size from 100 to 256 bytes
* remove implied flush from out2str(), in particular this avoids unnecessary
flushing in the middle of a -x tracing line
* rename dprintf() to out2fmt_flush(), make it flush out2 and use this
function in various places where flushing is desired after an error
message


# e68165a6 19-Jun-2009 Jilles Tjoelker <jilles@FreeBSD.org>

Fix some issues with quoted output and shorten it in some cases.

Output quoted suitable for re-input to the shell occurs in
various cases such as 'set', 'trap'.

Bugfix: *, ? and [ must be quoted (except sole [)
Bugfix: ~ and # must be quoted (really only sometimes, but keep it simple)
Bugfix: space, tab and newline must always be quoted
Shortening: other IFS characters do not need quoting
Bugfix: send to correct output file, not hard-coded stdout
Shortening: avoid unnecessary '' with \'

Approved by: ed (mentor)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 3f0131f6 08-Dec-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Print empty quotes ('') when an empty string is passed to outqstr().
This makes a difference for the trap builtin, where after "trap '' 0" we
printed "trap -- quit". This is wrong, because an empty action means to reset
the action to the default. A side effect of this commit is that empty
variables are now printed as "variable=''" instead of just "variable=".


# 6195fb41 06-Apr-2004 Mark Murray <markm@FreeBSD.org>

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 2ba1b30b 05-Jul-2003 Diomidis Spinellis <dds@FreeBSD.org>

Changes following CScout analysis:

- Removed dead declarations
- Made objects that should have been declared as static, static.

The changes use STATIC instead of static, following the existing
convention in the rest of the code.

Approved by: schweikh (mentor)
MFC after: 2 weeks


# 658a755b 01-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Back out experimental changes to fmtstr() that I didn't mean to include
in the previous commit.


# 7e73d40e 01-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Replace a home-grown printf() clone with a fwopen() wrapper around
libc's vfprintf() that writes to a `struct output' instead of a file.
Inspired by NetBSD's similar changes (they used asprintf() instead).


# 2749b141 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use FBSDID


# dee75cf7 05-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

Don't modify output that is to be quoted if it contains no IFS characters
or shell metacharacters.


# e5341cbb 03-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

Quote alias values in the output of the alias(1) builtin so they are
suitable for re-input to the shell (SUSv3)


# 5134c3f7 01-Feb-2002 Warner Losh <imp@FreeBSD.org>

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.
o Change
int
foo() {
...
to
int
foo(void)
{
...


# a2e73040 17-Apr-2001 Kris Kennaway <kris@FreeBSD.org>

-Wnon-const-format sweep: make format strings const char *'s, add
__printflike()/__printf0like() to function prototypes, as appropriate.

Reviewed by: bde, -audit


# 2a456239 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 3d7b5b93 18-May-1998 Philippe Charnier <charnier@FreeBSD.org>

Add rcsid. Spelling.


# f4eb55ba 27-Apr-1997 Steve Price <steve@FreeBSD.org>

Remove an extra semicolon and nuke register keyword usage.


# b97fa2ef 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# ab0a2172 13-Dec-1996 Steve Price <steve@FreeBSD.org>

Merge in NetBSD mods and -Wall cleaning.

Obtained from: NetBSD, me


# 4417f629 03-Sep-1996 Peter Wemm <peter@FreeBSD.org>

Fix for PR#1287. This makes sh behave sensibly in case statements in the
face of aliases. Note, bash doesn't do aliases while running scripts, but
"real" ksh does..

Also:
Reduce redundant .Nm macros in (unused) bltin/echo.1
nuke error2, it's hardly used.
More -Wall cleanups
dont do certain history operations if NO_HISTORY defined
handle quad_t's from resource limits

Submitted by: Steve Price <sprice@hiwaay.net> (minor tweaks by me)


# aa9caaf6 01-Sep-1996 Peter Wemm <peter@FreeBSD.org>

Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is a
merge of parallel duplicate work by Steve Price and myself. :-]

There are some changes to the build that are my fault... mkinit.c was
trying (poorly) to duplicate some of the work that make(1) is designed to
do. The Makefile hackery is my fault too, the depend list was incomplete
because of some explicit OBJS+= entries, so mkdep wasn't picking up their
source file #includes.

This closes a pile of /bin/sh PR's, but not all of them..

Submitted by: Steve Price <steve@bonsai.hiwaay.net>, peter


# 069428af 26-May-1996 Peter Wemm <peter@FreeBSD.org>

Import the 4.4BSD-Lite2 /bin/sh sources

Requested by: joerg

(Note, this is mostly going to be conflicts, which is expected. Our entire
sh source has a mainline, so this should not change anything except for
a few new files appearing. I dont think they are a problem)


# 89730b29 23-Sep-1994 David Greenman <dg@FreeBSD.org>

Added $Id$


# 4b88c807 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite bin Sources