History log of /freebsd-current/bin/sh/sh.1
Revision Date Author Comments
# 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


# a675eaec 01-Jan-2023 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

sh: implement PS1 \D to print current time

\D{format} yields the result of calling strftime(3) with the provided
format and the current time.

When PS4 can use this, it will enable us to easily generate timestamps
when tracing script execution.

Differential Revision: https://reviews.freebsd.org/D35840


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

Remove $FreeBSD$: one-line nroff pattern

Remove /^\.\\"\s*\$FreeBSD\$$\n/


# 3cf65f8a 08-Dec-2022 Juraj Lutter <otis@FreeBSD.org>

sh(1): Allow non-printing characters in prompt strings

Introduce new prompt format characters:

- '\[' starts the sequence of non-printing chatacters
- '\]' ends the sequence of non-printing characters

Within these sequences, the following characters are now supported:

- '\a' emits ASCII BEL (0x07, 007) character
- '\e' emits ASCII ESC (0x1b, 033) character
- '\r' emits ASCII CR (0x0d, 015) character
- '\n' emits ASCII CRLF sequence

These can be used to embed ANSI sequences into prompt strings.

Example in .shrc:

PS1="\[\e[7m\]\u@\h\[\e[0m\]:\w \\$ "

This tries to maintain some degree of compatibility with GNU bash,
that uses GNU readline library (which behaves slightly different from
BSD editline): It has two "non-printing boundary" characters:

- RL_PROMPT_START_IGNORE (\001)
- RL_PROMPT_END_IGNORE (\002)

while BSD editline only has one (when using EL_PROMPT_ESC setting), so
for this purpose, ASCII \001 was chosen and both \[ and \] emits
this character.

And while here, enlarge PROMPTLEN from 128 to 192 characters.

Reviewed by: jilles
Approved by: jilles
Differential Revision: https://reviews.freebsd.org/D37701


# 825225e5 14-Aug-2022 Jens Schweikhardt <schweikh@FreeBSD.org>

For man page references found in ports, indicate the respective port.


# b131efe3 31-Jul-2022 Gordon Bergling <gbe@FreeBSD.org>

sh.1: Fix a mandoc warning

- new sentence, new line

MFC after: 3 days


# d2c23317 23-Sep-2021 Stephane Rochoy <stephane.rochoy@stormshield.eu>

sh: Add -o verify to use O_VERIFY when sourcing scripts

Add -o verify to sh to make it use O_VERIFY when
sourcing scripts and reading profiles.

Useful in conjunction with mac_veriexec to help protect at
least some parts of the boot sequence, e.g., /etc/rc*.

Differential revision: https://reviews.freebsd.org/D30464
Reviewed by: jilles, sjg
Obtained from: Stormshield


# 988b1bb0 30-Mar-2021 Baptiste Daroussin <bapt@FreeBSD.org>

sh: implement persistent history storage

Implement persistent history storage:
the strategy is simple at start: loads the existing .sh_history file
at exit dump it.

The implementation respects the HISTFILE variable and its POSIX
definition: ~/.sh_history is used if HISTFILE is not set.

to avoid sh to create the history file, set HISTSIZE to 0 or HISTFILE to
en empty value

Co-authored-by: pstef
Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D29493


# 2c566d31 06-Jul-2020 Mateusz Piotrowski <0mp@FreeBSD.org>

Fix description of the "\$" sequence for PS1

The manual page documents "\$" to expand to either "$" or "#" followed by
a single space. In reality, the single space character is not appended.

PR: 247791
Submitted by: kd-dev@pm.me
MFC after: 7 days


# 484160a9 24-Feb-2019 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add set -o pipefail

The pipefail option allows checking the exit status of all commands in a
pipeline more easily, at a limited cost of complexity in sh itself. It works
similarly to the option in bash, ksh93 and mksh.

Like ksh93 and unlike bash and mksh, the state of the option is saved when a
pipeline is started. Therefore, even in the case of commands like
A | B &
a later change of the option does not change the exit status, the same way
(A | B) &
works.

Since SIGPIPE is not handled specially, more work in the script is required
for a proper exit status for pipelines containing commands such as head that
may terminate successfully without reading all input. This can be something
like

(
cmd1
r=$?
if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then
exit 0
else
exit "$r"
fi
) | head

PR: 224270
Relnotes: yes


# d81ca439 24-Jan-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make sh(1) support \u in PS1. This removes one fork/exec on interactive
shell startup.

Reviewed by: 0mp (man page), jilles
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D18790


# 1becbc64 07-Dec-2018 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Remove -c string from set builtin documentation

Altering the -c string at run time does not make sense and is not possible.

MFC after: 1 week


# 77da4a95 27-Nov-2018 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Use 126 and 127 exit status for failures opening a script

This affects scripts named on the command line, named with a '.' special
builtin and found via the PATH %func autoloading mechanism.

PR: 231986


# 17e98da8 19-Jul-2018 Mateusz Piotrowski <0mp@FreeBSD.org>

Describe how to prevent *.core files from being created using ulimit.

While here, pet mandoc.

Reviewed by: eadler (previous revision), jilles (previous revision), mat (mentor)
Approved by: manpages (jilles), mat (mentor)
Differential Revision: https://reviews.freebsd.org/D15609


# 6986f58f 23-Dec-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Markup and spelling fixes


# f3aff7c9 06-Dec-2017 Benjamin Kaduk <bjk@FreeBSD.org>

Fix mandoc -Tlint warnings in bin/

Many style-level issues are still reported.

Submitted by: Yuri Pankov <yuripv@gmx.com>
Reviewed by: jilles (previous revision)
Differential Revision: https://reviews.freebsd.org/D13334


# 6f49cd26 25-Jun-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Ignore error when cd writes the directory actually switched to.

If CDPATH is used non-trivially or the operand is "-", cd writes the
directory actually switched to. (We currently do this only in interactive
shells, but POSIX requires this in non-interactive shells as well.)

As mentioned in Austin group bug #1045, cd shall not return an error while
leaving the current directory changed. Therefore, ignore any write error.


# 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


# 33bf6c45 11-Feb-2017 Baptiste Daroussin <bapt@FreeBSD.org>

Remove empty Li

Reported by: make manlint
MFC after: 2 days


# 7cca93e6 08-Oct-2016 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Do not import IFS's value from the environment.

Per Austin group issue #884, always set IFS to $' \t\n'. As before, IFS will
be exported iff it was in the environment.

Most shells (e.g. bash, ksh93 and mksh) already did this. This change
improves predictability, in that scripts can simply rely on the default
value.

However, the effect on security is little, since applications should not be
calling the shell with attacker-controlled environment variable names in the
first place and other security-sensitive variables such as PATH should be
and are imported by the shell.

When using a new sh with an old (before 10.2) libc wordexp(), IFS is no
longer passed on. Otherwise, wordexp() continues to pass along IFS from the
environment per its documentation.

Discussed with: pfg
Relnotes: yes


# 2770ce60 30-May-2016 Warren Block <wblock@FreeBSD.org>

Clarify the explanations for the hostname and FQDN entries.

MFC after: 1 week


# ae100660 24-May-2016 Don Lewis <truckman@FreeBSD.org>

Match the descriptions of the \H and \h prompt string sequences to reality.
They were swapped.

X-Confirmed by: jilles
MFC after: 1 week


# 250d9fd8 12-Mar-2016 Konstantin Belousov <kib@FreeBSD.org>

Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add
login.conf(5) support.

Reviewed by: jilles
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D5610


# 7b6779b6 30-Jan-2016 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Document 'cd -'.

This reflects the changes in r294649 and can therefore not be MFCed by
itself.


# 62c37116 29-Aug-2015 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add set -o nolog.

POSIX requires this to prevent entering function definitions in history but
this implementation does nothing except retain the option's value. In ksh88,
function definitions were usually entered in the history file, even when
they came from ~/.profile and the $ENV file, to allow displaying their
definitions.

This is also the first option that does not have a letter.


# 8956c4ec 11-Jul-2015 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): libedit has supported multibyte encodings for a while.


# a59f8174 18-Apr-2015 Bryan Drewery <bdrewery@FreeBSD.org>

sh: Fix the trap builtin to be POSIX-compliant for 'trap exit SIG' and 'trap n n...'.

The parser considered 'trap exit INT' to reset the default for both EXIT and
INT. This beahvior is not POSIX compliant. This was avoided if a value was
specified for 'exit', but then disallows exiting with the signal received. A
possible workaround is using ' exit'.

However POSIX does allow this type of behavior if the parameters are all
integers. Fix the handling for this and clarify its support in the manpage
since it is specifically allowed by POSIX.

Differential Revision: https://reviews.freebsd.org/D2325
Reviewed by: jilles
MFC after: 2 weeks


# 4445af21 22-Feb-2015 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add details about importing the environment and initializing OPTIND.


# b1f60592 14-Nov-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Add/improve information about exit status of commands.


# 945e1562 07-Nov-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Mention portability issue with shifting zero positional parameters.

Per Austin Group issue #459, shifting zero positional parameters may or may
not be considered an operand error (which causes the shell to exit in most
cases).


# 000dda7b 21-Sep-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Clarify that assignments before commands do not affect expansions.

PR: 193759
MFC after: 1 week


# cd60e2c6 04-Sep-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Allow enabling job control without a tty in non-interactive mode.

If no tty is available, 'set -m' is still useful to put jobs in their own
process groups.


# 455b6546 24-Feb-2014 Daichi GOTO <daichi@FreeBSD.org>

sh: Add -h option to SYNOPSIS

Reviewed by: jilles
MFC after: soon


# 48f49aac 26-Jan-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Allow aliases to force alias substitution on the following word.

If an alias's value ends with a space or tab, the next word is also
checked for aliases.

This is a POSIX feature. It is useful with utilities like command and
nohup (alias them to themselves followed by a space).


# b14cfdf6 03-Jan-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Discourage use of -e.

Also, do not say that ! before a pipeline is an operator, because it is
syntactically a keyword.


# d2c068ea 01-Nov-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1),limits(1): Document kqueues (-k) rlimit.


# 2935c4cc 04-Sep-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Make return return from the closest function or dot script.

Formerly, return always returned from a function if it was called from a
function, even if there was a closer dot script. This was for compatibility
with the Bourne shell which only allowed returning from functions.

Other modern shells and POSIX return from the function or the dot script,
whichever is closest.

Git 1.8.4's rebase --continue depends on the POSIX behaviour.

Reported by: Christoph Mallon, avg


# 0c35cec6 14-Jun-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): A subshell environment has its own rlimits (ulimit).

This has always been the case and is intended (just like cd).

This matches Austin group issue #706.


# bd76c6b8 05-Jun-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Document new features in wait builtin.

PR: 176916


# c4539460 03-May-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Improve error handling in read builtin:

* If read -t times out, return status as if interrupted by SIGALRM
(formerly 1).
* If a trapped signal interrupts read, return status 128+sig (formerly 1).
* If [EINTR] occurs but there is no trap, retry the read (for example
because of a SIGWINCH in interactive mode).
* If a read error occurs, write an error message and return status 2.

As before, a variable assignment error returns 2 and discards the remaining
data read.


# 1ca3beb9 21-Apr-2013 Joel Dahl <joel@FreeBSD.org>

Document a few expansions for the $PS1 and $PS2 environmental variables.

PR: 173410
Submitted by: Derek Wood <ddwood@outlook.com>
Reviewed by: jilles


# 5127efa3 29-Mar-2013 Joel Dahl <joel@FreeBSD.org>

Minor mdoc fix.


# 54ccc8b5 24-Mar-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Mention possible ambiguities with $(( and ((.

In some other shells, things like $((a);(b)) are command substitutions.

Also, there are shells that have an extension ((ARITH)) that evaluates an
arithmetic expression and returns status 1 if the result is zero, 0
otherwise. This extension may lead to ambiguity with two subshells starting
in sequence.


# cb5a6a58 22-Jan-2013 Joel Dahl <joel@FreeBSD.org>

Add FILES section.

Discussed with: jilles


# 5dd78c9f 20-Jan-2013 Joel Dahl <joel@FreeBSD.org>

Change the $ENV example to use .shrc instead of .shinit. This is consistent
with what we use in /usr/share/skel/dot.profile.

Discussed with: jilles


# 523646ee 14-Jan-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Simplify cd-hash interaction.

Instead of rechecking relative paths for all hashed utilities after a cd,
track if any utility in cmdtable depends on a relative path in PATH.
If there is such a utility, cd clears the entire table.

As a result, the '*' in hash no longer happens.


# a2442c2f 14-Oct-2012 Joel Dahl <joel@FreeBSD.org>

mdoc: don't nest displays. The markup here isn't adding anything anyway.
Fixes a mandoc lint warning.

Discussed with: brueffer, Jason McIntyre <jmc@kerhand.co.uk>


# afc5a69a 11-Sep-2012 Joel Dahl <joel@FreeBSD.org>

Minor mdoc fix.


# 84fbdd8c 15-Jul-2012 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Expand assignment-like words specially for export/readonly/local.

Examples:
export x=~
now expands the tilde
local y=$1
is now safe, even if $1 contains IFS characters or metacharacters.

For a word to "look like an assignment", it must start with a name followed
by an equals sign, none of which may be quoted.

The special treatment applies when the first word (potentially after
"command") is "export", "readonly" or "local". There may be quoting
characters but no expansions. If "local" is overridden with a function there
is no special treatment ("export" and "readonly" cannot be overridden with a
function).

If things like
local arr=(1 2 3)
are ever allowed in the future, they cannot call a "local" function. This
would either be a run-time error or it would call the builtin.

This matches Austin Group bug #351, planned for the next issue of POSIX.1.

PR: bin/166771


# 35471bf8 13-May-2012 Joel Dahl <joel@FreeBSD.org>

Minor mdoc nits.


# 748611c9 07-Apr-2012 Joel Dahl <joel@FreeBSD.org>

mdoc: fix column names, indentation, column separation within each row, and
quotation. Also make sure we have the same amount of columns in each row as
the number of columns we specify in the head arguments.

Reviewed by: brueffer


# 50d675f7 28-Mar-2012 Eitan Adler <eadler@FreeBSD.org>

Remove trailing whitespace per mdoc lint warning

Disussed with: gavin
No objection from: doc
Approved by: joel
MFC after: 3 days


# 904d0726 25-Mar-2012 Joel Dahl <joel@FreeBSD.org>

Remove superfluous paragraph macro.


# ad56ebdc 05-Nov-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Improve documentation of field splitting.


# 51a514ad 10-Jul-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Extend documentation about subshells.

Because sh executes commands in subshell environments without forking in
more and more cases (particularly from 8.0 on), it makes sense to describe
subshell environments more precisely using ideas from POSIX, together with
some FreeBSD-specific items.

In particular, the hash and times builtins may not behave as if their state
is copied for a subshell environment while leaving the parent shell
environment unchanged.


# 519c4ef3 24-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Improve documentation of shell patterns:

* Shell patterns are also for ${var#pat} and the like.
* An '!' by itself will not trigger pathname generation so do not call it a
meta-character, even though it has a special meaning directly after an
'['.
* Character ranges are locale-dependent.
* A '^' will complement a character class like '!' but is non-standard.

MFC after: 1 week


# b97989d6 24-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Document the case command better.

Suggested by: netchild
Reviewed by: gjb


# 54b16435 18-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add do-nothing -h option.

POSIX requires a -h option to sh and set, to locate and remember utilities
invoked by functions as they are defined. Given that this
locate-and-remember process is optional elsewhere, it seems safe enough to
make this option do nothing.

POSIX does not specify a long name for this option. Follow ksh in calling it
"trackall".


# c9afaa63 17-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add case statement fallthrough (with ';&' instead of ';;').

Replacing ;; with the new control operator ;& will cause the next list to be
executed as well without checking its pattern, continuing until a list ends
with ;; or until the end of the case statement. This is like omitting
"break" in a C "switch" statement.

The sequence ;& was formerly invalid.

This feature is proposed for the next POSIX issue in Austin Group issue
#449.


# ff4dc672 15-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add support for named character classes in bracket expressions.

Example:
case x in [[:alpha:]]) echo yes ;; esac


# c543e1ae 12-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Save/restore changed variables in optimized command substitution.

In optimized command substitution, save and restore any variables changed by
expansions (${var=value} and $((var=assigned))), instead of trying to
determine if an expansion may cause such changes.

If $! is referenced in optimized command substitution, do not cause jobs to
be remembered longer.

This fixes $(jobs $!) again, simplifies the man page and shortens the code.


# 1a62d884 10-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Do parameter expansion on ENV before using it.

This is required by POSIX, and allows things like ENV=\$HOME/.shrc.

Note that tilde expansion is explicitly not performed.


# 292e6676 09-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Do parameter expansion before printing PS4 (set -x).

The function name expandstr() and the general idea of doing this kind of
expansion by treating the text as a here document without end marker is from
dash.

All variants of parameter expansion and arithmetic expansion also work (the
latter is not required by POSIX but it does not take extra code and many
other shells also allow it).

Command substitution is prevented because I think it causes too much code to
be re-entered (for example creating an unbounded recursion of trace lines).

Unfortunately, our LINENO is somewhat crude, otherwise PS4='$LINENO+ ' would
be quite useful.


# 05a447d0 21-May-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Expand aliases after assignments and redirections.


# d6ee26ad 20-May-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Implement the cd -e flag proposed for the next POSIX issue.

This reflects failure to determine the pathname of the new directory in the
exit status (1). Normally, cd returns successfully if it did chdir() and the
call was successful.

In POSIX, -e only has meaning with -P; because our -L is not entirely
compliant and may fall back to -P mode, -e has some effect with -L as well.


# 07eb7033 08-May-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add \u/\U support (in $'...') for UTF-8.

Because we have no iconv in base, support for other charsets is not
possible.

Note that \u/\U are processed using the locale that was active when the
shell started. This is necessary to avoid behaviour that depends on the
parse/execute split (for example when placing braces around an entire
script). Therefore, UTF-8 encoding is implemented manually.


# 50df3424 08-May-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Update BUGS section for UTF-8 support.


# a62ab027 05-May-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add $'quoting' (C-style escape sequences).

A string between $' and ' may contain backslash escape sequences similar to
the ones in a C string constant (except that a single-quote must be escaped
and a double-quote need not be). Details are in the sh(1) man page.

This construct is useful to include unprintable characters, tabs and
newlines in strings; while this can be done with a command substitution
containing a printf command, that needs ugly workarounds if the result is to
end with a newline as command substitution removes all trailing newlines.

The construct may also be useful in future to describe unprintable
characters without needing to write those characters themselves in 'set -x',
'export -p' and the like.

The implementation attempts to comply to the proposal for the next issue of
the POSIX specification. Because this construct is not in POSIX.1-2008,
using it in scripts intended to be portable is unwise.

Matching the minimal locale support in the rest of sh, the \u and \U
sequences are currently not useful.

Exp-run done by: pav (with some other sh(1) changes)


# ef89d04f 20-Mar-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Describe subshell environment, command substitution more correctly.

POSIX does not require the shell to fork for a subshell environment, and we
use that possibility in various ways (command substitutions with a single
command and most subshells that are the final command of a shell process).
Therefore do not tie subshells to forking in the man page.

Command substitutions with expansions are a bit strange, causing a fork for
$(...$(($x))...) because $x might expand to y=2; they will probably be
changed later but this is how they work now.


# ea381e69 06-Mar-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Reduce excessive semicolon-separated sentences.

Reported by: Benjamin Kaduk


# 075b72ef 08-Feb-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Update description of arithmetic.


# 604e8224 04-Feb-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Do not try to execute binary files as scripts.

If execve() returns an [ENOEXEC] error, check if the file is binary before
trying to execute it using sh. A file is considered binary if at least one
of the first 256 bytes is '\0'.

In particular, trying to execute ELF binaries for the wrong architecture now
fails with an "Exec format error" message instead of syntax errors and
potentially strange results.


# 3835f47c 04-Feb-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Remove special code for shell scripts without magic number.

These are called "shell procedures" in the source.

If execve() failed with [ENOEXEC], the shell would reinitialize itself
and execute the program as a script. This requires a fair amount of code
which is not frequently used (most scripts have a #! magic number).
Therefore just execute a new instance of sh (_PATH_BSHELL) to run the
script.


# 421fb021 16-Jan-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Document changes to 'exit' from traps.


# 12dfb7a5 21-Dec-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Explain why it is a bad idea to use aliases in scripts.


# 0a62a9ca 21-Dec-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add kill builtin.

This allows specifying a %job (which is equivalent to the corresponding
process group).

Additionally, it improves reliability of kill from sh in high-load
situations and ensures "kill" finds the correct utility regardless of PATH,
as required by POSIX (unless the undocumented %builtin mechanism is used).

Side effect: fatal errors (any error other than kill(2) failure) now return
exit status 2 instead of 1. (This is consistent with other sh builtins, but
not in NetBSD.)

Code size increases about 1K on i386.

Obtained from: NetBSD


# 25f6b31f 03-Dec-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Clean up documentation of built-in commands.

Make sure all built-in commands are in the subsection named such, except
exp, let and wordexp which are deliberately undocumented. The text said only
built-ins that really need to be a built-in were documented there but in
fact almost all of them were already documented.


# b97d13b3 01-Dec-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Document that command's -p option also works with -v/-V.

This was implemented in r201343.


# 9897c45f 18-Nov-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add printf builtin.

This was removed in 2001 but I think it is appropriate to add it back:
* I do not want to encourage people to write fragile and non-portable echo
commands by making printf much slower than echo.
* Recent versions of Autoconf use it a lot.
* Almost no software still wants to support systems that do not have
printf(1) at all.
* In many other shells printf is already a builtin.

Side effect: printf is now always the builtin version (which behaves
identically to /usr/bin/printf) and cannot be overridden via PATH (except
via the undocumented %builtin mechanism).

Code size increases about 5K on i386. Embedded folks might want to replace
/usr/bin/printf with a hard link to /usr/bin/alias.


# 4b985a89 12-Nov-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Document r214304 (special builtin is illegal function name).


# f35d74be 12-Nov-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Update for r214492. "${v+"hi}there"}".

The part hi}there is not a quoted string but nevertheless the closing brace
does not terminate the expansion.


# 3fdfd0a4 12-Nov-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Modernize the introduction a bit.

In particular, remove the text about ksh-like features, which are usually
taken for granted nowadays. The original Bourne shell is fading away and for
most users our /bin/sh is one of the most minimalistic they know.


# 57a40f7d 31-Oct-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Correct synopsis and make precise how $0 is set.

In particular, the extra argument to set $0 with -c was not documented.

MFC after: 1 week


# 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.


# f1ec0581 16-Oct-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Clarify subshells/processes for pipelines.

For multi-command pipelines,
1. all commands are direct children of the shell (unlike the original
Bourne shell)
2. all commands are executed in a subshell (unlike the real Korn shell)

MFC after: 1 week


# 1217a4ea 10-Sep-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Remove xrefs for expr(1) and getopt(1).

expr(1) should usually not be used as various forms of parameter expansion
and arithmetic expansion replicate most of its functionality in an easier
way.

getopt(1) should not be used at all in new code. Instead, getopts(1) or
entirely manual parsing should be used.

MFC after: 1 week


# 36cf3efe 22-Aug-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Add a brief summary of arithmetic expressions.


# ed4c3b5f 29-Jun-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Forget about terminated background processes sooner.

Unless $! has been referenced for a particular job or $! still contains that
job's pid, forget about it after it has terminated. If $! has been
referenced, remember the job until the wait builtin has reported its
completion (either with the pid as parameter or without parameters).

In interactive mode, jobs are forgotten after termination has been reported,
which happens before primary prompts and through the jobs builtin. Even
then, though, remember a job if $! has been referenced.

This is similar to what is suggested by POSIX and should fix most memory
leaks (which also tend to cause sh to use more CPU time) with long running
scripts that start background jobs.

Caveats:
* Repeatedly referencing $! without ever doing 'wait', like
while :; do foo & echo started foo: $!; sleep 60; done
will still use a lot of memory and CPU time in the long run.
* The jobs and jobid builtins do not cause a job to be remembered for longer
like expanding $! does.

PR: bin/55346


# 1788b7ff 24-May-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Rework documentation of shell variables.

* Move the "environment variables" that do not need exporting to be
effective or that are set by the shell without exporting to a new section
"Special Variables".
* Add special variables LINENO and PPID.
* Add environment variables LANG, LC_* and PWD; also describe ENV under
environment variables.


# 626a7b1d 24-May-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Improve wording of 'Special Parameters' section.


# d806a030 09-May-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Fix "reserved word" vs "keyword" inconsistency.
Use "keyword" everywhere, like the output of the 'type' builtin, and only
mention "reserved word" once to say it is the same thing.


# 1f7026c7 23-Apr-2010 Jilles Tjoelker <jilles@FreeBSD.org>

MFC r197848: Clarify quoting of word in ${v=word} in sh(1).


# d5f6b530 05-Apr-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Automatically enable -o emacs in interactive shells with terminals.

This makes sh a bit more friendly in single user mode, make buildenv, chroot
and the like, and matches other shells.

The -o emacs can be overridden on the command line or in the ENV file.


# 227c8e2a 04-Apr-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Document the expansion changes in the man page.

Note that the following sentence
> Enclosing the full parameter expansion string in double-quotes does not
> cause the following four varieties of pattern characters to be quoted,
> whereas quoting characters within the braces has this effect.
is now true, but used to be incorrect.


# 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.


# c848bc18 06-Mar-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Improve the command builtin:
* avoid unnecessary fork
* allow executing builtins via command
* executing a special builtin via command removes its special properties

Obtained from: NetBSD (parts)


# e859c2af 08-Jan-2010 Jilles Tjoelker <jilles@FreeBSD.org>

MFC r201355: sh(1): document ulimit -w (swapuse rlimit).


# 716779e2 08-Jan-2010 Jilles Tjoelker <jilles@FreeBSD.org>

MFC r201354: sh(1): Correct two places where "$@" lacked necessary quotes.


# c8054a61 31-Dec-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): document ulimit -w (swapuse rlimit).

MFC after: 1 week


# 776e6b33 31-Dec-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh(1): Correct two places where "$@" lacked necessary quotes.

MFC after: 1 week


# defb74dc 29-Oct-2009 Jilles Tjoelker <jilles@FreeBSD.org>

MFC r197371: Mention that NUL characters are not allowed in sh(1) input.

I do not consider this a bug because POSIX permits it and argument strings
and environment variables cannot contain '\0' anyway.

PR: bin/25542


# 64254a66 24-Oct-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Exempt $@ and $* from set -u

This seems more useful and will likely be in the next POSIX standard.

Also document more precisely in the man page what set -u does (note that
$@, $* and $! are the only special parameters that can ever be unset, all
the others are always set, although they may be empty).


# b139165c 07-Oct-2009 Jilles Tjoelker <jilles@FreeBSD.org>

Clarify quoting of word in ${v=word} in sh(1).


# 9764aa41 20-Sep-2009 Jilles Tjoelker <jilles@FreeBSD.org>

Mention that NUL characters are not allowed in sh(1) input.

I do not consider this a bug because POSIX permits it and argument strings
and environment variables cannot contain '\0' anyway.

PR: bin/25542
MFC after: 2 weeks


# 30268dfa 24-Jun-2009 Jilles Tjoelker <jilles@FreeBSD.org>

Designate special builtins as such in command -V and type.
Also document various properties of special builtins that we implement.

Approved by: ed (mentor) (implicit)


# a68fbc44 07-Jun-2009 Jilles Tjoelker <jilles@FreeBSD.org>

Mention the range for the exit status for the exit special builtin.

The exit status may exceed 255 in some cases (return); even though it seems
unwise to rely on this, it is also unwise to assume that $? is always
between 0 and 255.

This resolves bin/124748 by documenting that 'exit -1' is not valid.

PR: bin/124748
Approved by: ed (mentor)


# fe40d6d3 31-May-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Make read's timeout (-t) apply to the entire line, not only the first
character.

This avoids using non-standard behaviour of the old (upto FreeBSD 7) TTY
layer: it reprocesses the input queue when switching to canonical mode. The
new TTY layer does not provide this functionality and so read -t worked
very poorly (first character is not echoed, cannot be backspaced but is
still read).

This also agrees with what most other shells with read -t do.

PR: bin/129566
Reviewed by: stefanf
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.


# 331773cd 30-Aug-2008 Ed Schouten <ed@FreeBSD.org>

Document the ulimit -p option in the sh(1) manual page.

When I imported the MPSAFE TTY code, I added the -p flag to sh(1)'s
ulimit, but I forgot to document it in the appropriate manual page.

Requested by: stefanf


# dfe302ab 04-Dec-2007 Ruslan Ermilov <ru@FreeBSD.org>

Revise the markup.


# aafd6a87 04-Oct-2007 Stefan Farfeleder <stefanf@FreeBSD.org>

The exit status of a case statement where none of the patterns is matched
is supposed to be 0, not the status of the previous command.

Reported by: Eygene Ryabinkin
PR: 116559
Approved by: re (gnn)


# de37e41c 07-Oct-2006 Stefan Farfeleder <stefanf@FreeBSD.org>

Add the POSIX option -p to the jobs builtin command. It prints the PID of the
process leader for each job. Now the last specified option for the output
format (-l, -p or -s) wins, previously -s trumped -l.

PR: 99926
Submitted by: Ed Schouten and novel (patches modified by me)


# 9badf57f 17-Sep-2006 Ruslan Ermilov <ru@FreeBSD.org>

Markup fixes.


# 9cdd1e3f 29-Jul-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Tell more of the sh(1) history.
Acknowledge Kenneth Almquist's contribution in AUTHORS.

MFC after: 5 days


# 10845922 26-Jul-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Make it easier to find that we have test(1) built-in in sh(1).

MFC after: 3 days


# a6557dcb 20-Jun-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Document the fact that 'true' and 'false' are among sh(1) built-in commands.

MFC after: 3 days


# 120c8e6c 15-Jun-2006 Stefan Farfeleder <stefanf@FreeBSD.org>

Implement the PS4 variable which is defined by the POSIX User Portability
Utilities option. Its value is printed at the beginning of the line if tracing
(-x) is active. PS4 defaults to the string "+ " which is compatible with the
old behaviour to always print "+ ".

We still need to expand variables in PS1, PS2 and PS4.

PR: 46441 (part of)
Submitted by: schweikh
Obtained from: NetBSD


# 7d1a55fc 01-Jan-2006 Stefan Farfeleder <stefanf@FreeBSD.org>

Document that '#' starts a comment.

PR: 85103
Submitted by: garys
Obtained from: pdksh manual
Patch from: Daniel Gerzo (with changes by me)


# 0673e800 08-Dec-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

- Document trap's -l option and the behaviour of a missing action or a single
dash.
- Discourage the omission of the action.

PR: 70985 [1]
Submitted by: Martin Kammerhofer


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

Clarify that the echo builtin takes an arbitrary number of strings.
Mention that spaces are printed between the strings.


# 1974986a 04-Dec-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Add the times builtin. It reports the user and system time for the shell
itself and its children. Instead of calling times() (as implied by POSIX) this
implementation directly calls getrusage() to get the times because this is more
convenient.


# 8af11131 16-Nov-2005 Ruslan Ermilov <ru@FreeBSD.org>

-mdoc sweep.


# d2f90294 02-Nov-2005 Jesus R. Camou <jcamou@FreeBSD.org>

Add `local' and `return' to the list of built-ins.

Submitted by: garys
Approved by: trhodes (mentor)


# 33b222b9 29-Oct-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Document command -v and -V.

Glanced at by: simon


# 1b161559 29-Oct-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Document that read -t timeout returns 1 if the timeout elapses.


# 74053659 10-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Elaborate on the behaviour of set -e.


# ef9791a3 09-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Split the export synopsis into two lines as -p cannot be mixed with variable
names.


# 7b14d37f 06-Sep-2005 Ralf S. Engelschall <rse@FreeBSD.org>

fix typo: ommitted -> omitted


# a01459df 03-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Document that `in word ...' is optional in the for command.


# de4ad382 02-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Document that unalias can be used to remove several alias names.


# 19162ab9 29-Aug-2005 Jesus R. Camou <jcamou@FreeBSD.org>

Wrap a line due to a new sentence.

Noticed by: simon
Approved by: trhodes (mentor)


# a886288e 29-Aug-2005 Jesus R. Camou <jcamou@FreeBSD.org>

o Discuss the ways to escape an alias.
o Fix the alias syntax lines.
o Refer to the Aliases subsection.

PR: docs/84914
Submitted by: garys
Approved by: trhodes (mentor)
MFC after: 3 days


# faa1ed35 17-Aug-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Document umask's -S option.


# fb039b55 14-Jun-2005 Ruslan Ermilov <ru@FreeBSD.org>

Sorted sections and fixed prompt (PS[12]) strings.

Approved by: re (blanket)


# fd50df30 14-Jun-2005 Ruslan Ermilov <ru@FreeBSD.org>

Put the description of the -c option in the right place, as
promised by the Argument List Processing section introduction.
What follows the option in the options list is its long name,
not its argument (as is the case for the -c option). Also
sort references in the SEE ALSO section.

Approved by: re (blanket)


# 38afdcbc 15-Apr-2005 Giorgos Keramidas <keramida@FreeBSD.org>

Various sh(1) enhancements:
- Move the description of the ``-c string'' option closer to the option itself.
- Add an ENVIRONMENT section (1)
- Add more .Xr cross references to the SEE ALSO section.

Obtained from: NetBSD (1)


# a762afe5 04-Mar-2005 Giorgos Keramidas <keramida@FreeBSD.org>

Use ``.Pq Ql'' to quote single characters, instead of ``.Pq Li''.
This makes the resulting output more aesthetically pleasing in
text-only terminals:

Reviewed by: ru


# 91ee1c5d 03-Mar-2005 Giorgos Keramidas <keramida@FreeBSD.org>

Add a section describing the exit status of the shell.

Obtained from: NetBSD


# 9ddb49cb 10-Jan-2005 Warner Losh <imp@FreeBSD.org>

/*- or .\"- or #- to begin license clauses.


# 6fa13ec0 09-Jan-2005 Ruslan Ermilov <ru@FreeBSD.org>

Scheduled mdoc(7) sweep.


# 6b4bbd8a 03-Jan-2005 Ceri Davies <ceri@FreeBSD.org>

Correct typo.


# af5eb6fc 02-Dec-2004 Maxim Konovalov <maxim@FreeBSD.org>

o Add a missed "." .

Reviewed by: ru
MFC after: 3 weeks


# 43d6677b 01-Nov-2004 Alfred Perlstein <alfred@FreeBSD.org>

When listing the special $ variables, ($!, $#, etc) list them as $!
instead of just !, this allows one to more easily locate/understand
the section of the manpage in question.

Additional wording correction by: keramida
Reviewed by: keramida


# 128dc4a2 02-Jul-2004 Tim J. Robbins <tjr@FreeBSD.org>

Document missing multibyte character handling in utilities specified
by POSIX.


# eccea571 02-Jul-2004 Ruslan Ermilov <ru@FreeBSD.org>

Mechanically kill hard sentence breaks.


# 4ad8968a 14-Apr-2004 Brian Feldman <green@FreeBSD.org>

Document the "return" built-in better: it will exit . (sources) and
the top-level shell instance, too.


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

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# fe08efe6 08-Sep-2003 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7): Use the new feature of the .In macro.


# d74e011f 16-May-2003 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: A better version of the same.

Approved by: re (blanket)


# fbc8f8a2 30-Apr-2003 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix references to non-existing or obsoleted man pages.

PR: docs/51480 (only a small part)
Submitted by: Diomidis D. Spinellis <dds@aueb.gr>


# e9fa8fdd 11-Apr-2003 Tim J. Robbins <tjr@FreeBSD.org>

Document the -L and -P options to the cd and pwd commands as being
mutually exclusive. The fact that the most recent one specified on the
command line is the one that takes effect is an implementation detail and
users should not rely on this.


# 1413f7de 03-Feb-2003 Tony Finch <fanf@FreeBSD.org>

Improve the layout of the description of the various parameter expansion
modifiers. The paragraph that explains the difference between ${foo:-bar}
and ${foo-bar} etc. was not very visible.


# facc6767 24-Dec-2002 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: Deal with self-xrefs.


# f5d1157f 23-Dec-2002 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: markup nit.


# 304199ce 17-Dec-2002 Tom Rhodes <trhodes@FreeBSD.org>

The code uses trapsasync, however the manual page uses asynctraps. Fix the
manual page to reflect the code.

PR: 45820
Submitted by: Marco Molteni <molter@tin.it>
Discussed with: tjr


# 162ae3ae 17-Dec-2002 Tony Finch <fanf@FreeBSD.org>

Document `trap EXIT` and `trap SIGNAME`.


# df9e587b 23-Aug-2002 Tim J. Robbins <tjr@FreeBSD.org>

There is a built-in command called "builtin"; spell its name correctly
after rev. 1.77 called it "built-in".


# 7d971bbf 21-Aug-2002 Tom Rhodes <trhodes@FreeBSD.org>

s/filesystem/file system/ as discussed on -developers


# 8eed22b1 21-Aug-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix a few typos, among them s/builtin/built-in/ (except for the ref
to the builtin(1) man page.) This is for consistency with the spelling
both proposed by ispell as well as IEEE Std 1003.1-2001.

MFC after: 3 days


# 9ba31ca0 09-Aug-2002 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: tidying.


# 7e1975c2 25-Jul-2002 Tim J. Robbins <tjr@FreeBSD.org>

Add a -P/-o physical option which behaves similarly to bash/ksh's options
by the same name. This option makes the cd and pwd builtins behave physically
(as opposed to logically) by default.

Submitted by: fanf


# 088acf90 23-Jul-2002 Tim J. Robbins <tjr@FreeBSD.org>

Add a `bind' builtin command, which is simply a wrapper around libedit's
builtin command of the same name. This allows the key bindings for the
shell's line editor to be changed.

MFC after: 2 weeks


# 2babaf74 21-Jul-2002 Tim J. Robbins <tjr@FreeBSD.org>

Implement the P1003.2 `command' builtin command, which is used to suppress
shell function and alias lookup. The -p option has been implemented, the
UPE -v and -V options have not. The old `command' command has been renamed
to `builtin'.


# 558175ca 19-Jul-2002 Tim J. Robbins <tjr@FreeBSD.org>

Document that only one of the -n and -e options may be specified for
sh(1)'s echo(1) builtin command.

PR: 32935, 40747
MFC after: 1 week


# 2d41ef4b 02-Jul-2002 Matthew Dillon <dillon@FreeBSD.org>

Fix type-o in last commit in preparation for MFC.


# 62df9b62 27-Jun-2002 Sheldon Hearn <sheldonh@FreeBSD.org>

Document addition of RLIMIT_VMEM support, added in rev 1.26 of miscbltin.c.


# 029c8ee4 18-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

Bring documentation on CDPATH and its effects on cd(1) back into sync with
reality (and POSIX): current directory isn't searched unless CDPATH has
a "." element or is unset.

PR: 38442
Submitted by: oleg dashevskii <be9@be9.ru>
MFC after: 1 week


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

Document the -f and -v options of the unset builtin.


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

Add the SUSv3 -p ("portable") option to both the export and readonly
builtins. This makes export/readonly print lines in the form
"export name=value".


# 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)


# ad8a0759 31-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Add -s (output PID's only) and -l (show PID's) options to the jobs(1)
builtin. Modify the output format to match what SUSv3 requires.


# 81e9cda2 29-May-2002 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: tidy up the markup a bit.


# fc482908 24-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

sh appeared in Version 1, not System V.1.


# d513af6a 24-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Implement `set +o', which displays the currently set options in a format
suitable for re-input into the shell.


# 178897f1 20-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Add the SUSv3 -L and -P options to the cd and pwd builtin utilities. `Logical'
handling of .. is now the default.


# 1b5a48ff 19-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Implement the -u (-o nounset) option, which gives an error message if
an unset variable is expanded.

Obtained from: NetBSD (bjh21, christos)


# 1a958c66 19-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Implement the -C (-o noclobber) option, which prevents existing regular
files from being overwritten by shell redirection.


# 018d9f62 20-Nov-2001 Akinori MUSHA <knu@FreeBSD.org>

Remove the printf builtin command from sh(1), which command is not
used so often that it's worth keeping it as a builtin.

Now that all the printf invocations from within the system startup
scripts, we can safely remove it.

Urged by: sheldonh :)

No MFC is planned so far because it may break compatibility and
violate POLA.


# d90c5c4a 17-Nov-2001 Akinori MUSHA <knu@FreeBSD.org>

Make test(1) a builtin command of our sh(1) for efficiency. The
binary size increase is 3,784 bytes (about 0.6%).

I don't drop the printf builtin while I'm here because some /etc/rc.*
scripts seem to use it before mounting /usr where printf(1) resides.

Reviewed by: arch (sheldonh)
Inspired by: NetBSD, ksh
Clued by: ume (on how the printf builtin is used)


# 42abf713 08-Aug-2001 Sheldon Hearn <sheldonh@FreeBSD.org>

can not -> cannot


# c4d9468e 07-Aug-2001 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police:

Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.


# 71337c33 23-Jul-2001 Sheldon Hearn <sheldonh@FreeBSD.org>

Break the list of parameter expansions into two lists so that
the paragraph introducing the prefix and suffix pattern expansions
does not appear as part of the explanation for the string length
expansion.


# caa2db3b 10-Jul-2001 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: removed HISTORY info from the .Os call.


# 5521ff5a 06-Jul-2001 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: sort SEE ALSO xrefs (sort -b -f +2 -3 +1 -2).


# a910f192 23-Jun-2001 Dima Dorfman <dd@FreeBSD.org>

Remove duplicate words.


# 9434a1c7 27-Apr-2001 Dima Dorfman <dd@FreeBSD.org>

Document "chdir" builtin.


# d0353b83 01-Feb-2001 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: split punctuation characters + misc fixes.


# 32f6256a 16-Jan-2001 Ruslan Ermilov <ru@FreeBSD.org>

Prepare for mdoc(7)NG.


# 1586940e 18-Dec-2000 Ruslan Ermilov <ru@FreeBSD.org>

Prepare for mdoc(7)NG.


# 12e720d7 15-Dec-2000 Ruslan Ermilov <ru@FreeBSD.org>

Prepare for mdoc(7)NG.


# b4f0f4aa 22-Nov-2000 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: Er macro usage cleanup.


# 4682f420 03-Oct-2000 Brian Somers <brian@FreeBSD.org>

Implement the <> redirection operator.


# 1b9735e6 24-Jul-2000 Sheldon Hearn <sheldonh@FreeBSD.org>

Mark up the -a flag to unalias as a flag (Fl), not an argument (Ar).


# 5d3b843b 24-Jul-2000 Sheldon Hearn <sheldonh@FreeBSD.org>

Add missing punctuation to one line.


# 501e74b7 17-Jul-2000 Mark Ovens <marko@FreeBSD.org>

Document the builtin echo command

Reviewed by: Matthew Hunt <mph@astro.caltech.edu>


# 3652a236 15-Dec-1999 Martin Cracauer <cracauer@FreeBSD.org>

Document ulimit -b for RLIMIT_SBSIZE.


# 67135607 04-Dec-1999 Martin Cracauer <cracauer@FreeBSD.org>

make '|' character visible.

PR: docs/15265
Submitted by: takamune@avrl.mei.co.jp


# e918fc8f 18-Nov-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Follow-up on mdoc fixes in rev 1.35; this includes things that I missed
in that revision as well as things I broke in that revision. A note-
worthy instance of the latter case was the inversion of -E and -V in the
subsection on Commandline Editing.


# 150c3a33 10-Nov-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Don't call bash(1) a Korn shell clone. Instead, use pdksh(1) as an
example of such a clone.

PR: 14601
Submitted by: Matthias Buelow <mkb@altair.mayn.de>


# 49e11e3a 07-Oct-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Mdoc cleanup, with a few grammar cleanups on the side.

Reviewed by: mpp


# e6d3cf26 14-Sep-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Correct some hard sentence breaks. Only those surrounding the previous
commit and those which cause ugly nroff output have been fixed, since
the purpose of the style guideline which they contravene is to reduce
the sizes of deltas.

Reported by: bde


# c644db6a 08-Sep-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Improve shell documentation:

* Consistently misspell built-in as builtin.

* Add a builtin(1) manpage and create builtin(1) MLINKS for all shell
builtin commands for which no standalone utility exists. These MLINKS
replace those that were created for csh(1).

* Add appropriate xrefs for builtin(1) to the csh(1) and sh(1) manpages,
as well as to the manpages of standalone utilities which are supported
as shell builtin commands in at least one of the shells. In such
manpages, explain that similar functionality may be provided as a
shell builtin command.

* Improve sh(1)'s description of the cd builtin command. Csh(1) already
describes it adequately. Replace the cd(1) manpage with a builtin(1)
MLINKS link.

* Clean up some mdoc problems: use Xr instead of literal "foo(n)"; use
Ic instead of Xr for shell builtin commands.

* Undo English contractions.

Reviewed by: mpp, rgrimes


# ccbd3081 30-Aug-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Revert to using .Xr for builtins. The cross-references don't work now,
but that doesn't mean that they will never work.

Requested by: mpp, rgrimes


# 6b15476e 30-Aug-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Clean-up:

Fix grammar and spelling nits.
Use .Dq and .Qq where appropriate.
Divorce trailing punctuation from quoted elements.
Use .Dq instead of .Xr for builtins.
Remove trailing whitespace and blank lines.

PR: 13340


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

$Id$ -> $FreeBSD$


# 8f0561cc 26-Aug-1999 Thomas Gellekum <tg@FreeBSD.org>

Make the behaviour of `read -e', ie. treating backslashes as special,
the default. Add -r option for the read builtin to reverse this.

PR: 13274
Reviewed by: cpiazza, hoek, sheldonh


# 120ac26d 19-Apr-1999 Masafumi Max NAKANE <max@FreeBSD.org>

Typo fix.


# b8ec435e 03-Apr-1999 Martin Cracauer <cracauer@FreeBSD.org>

Implement -a flag. A test shell script can be found at
http://www.cons.org/cracauer/download/sh-interrupt/testsuite/test_export.sh
The PR also had test cases the new version passes.

Fix typo in comment.

PR: bin/1030


# 2870f7a8 02-Apr-1999 Martin Cracauer <cracauer@FreeBSD.org>

-T was missing in the synopsis line.

Submitted by: BDE


# c1c72a3c 01-Apr-1999 Martin Cracauer <cracauer@FreeBSD.org>

The immediate execution of traps I introduced in September 1998 (to
make /etc/rc interruptible in cases when programs hang with blocked
signals) isn't standard enough.

It is now switched off by default and a new switch -T enables it.

You should update /etc/rc to the version I'm about to commit in a few
minutes to keep it interruptible.


# 71405fb6 31-Mar-1999 Brian Somers <brian@FreeBSD.org>

sh doesn't support <> redirections.
PR: 7325


# c83e7c50 17-Dec-1998 Joseph Koshy <jkoshy@FreeBSD.org>

Add references to test(1) and expr(1).


# 0bd063bc 02-Dec-1998 Bill Fumerola <billf@FreeBSD.org>

Fix typo. "If the an entry" --> "If an entry"

PR: docs/8140
Submitted by: Sue Blake <sue@vedanix.welearn.com.au>


# fab26805 29-Jul-1998 Joseph Koshy <jkoshy@FreeBSD.org>

Document behaviour of "-" and "--" on the command line.

PR: docs/5399


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

Add rcsid. Spelling.


# 6466945a 11-Feb-1998 John Polstra <jdp@FreeBSD.org>

Explicitly describe the rules the shell uses to search for a file
sourced by the "." command.


# ee7dc416 02-Jan-1998 Steve Price <steve@FreeBSD.org>

Correct a bogon in an example.

PR: 5415
Submitted by: Sergei S. Laskavy <laskavy@pc759.cs.msu.su>


# c351e089 11-Nov-1997 John Polstra <jdp@FreeBSD.org>

Document the exit status for a command that was terminated by a
signal.


# afa53c8d 29-Sep-1997 Mike Smith <msmith@FreeBSD.org>

Add the '-t timeout' option to the 'read' builtin. This allows the
'read' command to return an error if the user fails to supply any
input withink a given time period. The behaviour of this option is
similar to that of the like-named option in ksh93.

Reviewed by: joerg


# c7a197e1 13-Sep-1997 Wolfram Schneider <wosch@FreeBSD.org>

PR: docs/4449
The -c flag is not documented in the sh(1) manapge.

Submitted by: adrian@virginia.edu


# ea76be72 07-May-1997 Steve Price <steve@FreeBSD.org>

Revise the section that explains how to protect parts of an $ENV script
from being executed in non-interactive mode.

Suggested and Reviewed by: Brian Somers <brian@freebsd.org>


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

mdoc-ify and cleanup UNIMPLEMENTED messages. Closes PR 2880.


# 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


# 621a31c6 28-Oct-1996 Steve Price <steve@FreeBSD.org>

Add the -p (privileged) commandline switch
found in bash, zsh, and friends.

Reviewed by: joerg


# 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


# b8923d4c 29-Aug-1996 Wolfram Schneider <wosch@FreeBSD.org>

[HISTORY] command appeared in Version 1 AT&T UNIX
Obtained from: A Quarter Century of UNIX, Peter H. Salus, page 41


# 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)


# 769bbc65 20-Oct-1995 Joerg Wunsch <joerg@FreeBSD.org>

o rename ulimit -p into ulimit -u, so we are in agreement with bash

o fix brokeness for 1>&5 redirection, where `5' was an invalid file
descriptor, but no error message has been generated

o fix brokeness for redirect to/from myself case


# 7a2afe64 19-Oct-1995 Joerg Wunsch <joerg@FreeBSD.org>

Implement the "ulimit" builtin. This is the analogon to csh's "limit"
command and badly needed in sh(1) for everybody who wants to modify
the system-wide limits from inside /etc/rc.

The options are similar to other system's implemantations of this
command, with the FreeBSD additions for -m (memoryuse) and -p (max
processes) that are not available on other systems.


# f434d1df 05-May-1995 Adam David <adam@FreeBSD.org>

typo there --> their


# 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