Commit Graph

2783 Commits

Author SHA1 Message Date
Joel Dahl
afc5a69a1d Minor mdoc fix. 2012-09-11 17:57:03 +00:00
Jilles Tjoelker
36f7fbeae8 sh: Remove XXX comment about removing nextopt().
Using nextopt() avoids depending on the BSD-specific optreset feature in
getopt() and reduces code size (both source and binary).
2012-09-08 19:24:03 +00:00
Kevin Lo
d11ed2f6de Use "e.g.", not "i.e.", to introduce an example.
Obtained from:	NetBSD
2012-09-07 09:00:25 +00:00
Edward Tomasz Napierala
c55e0c62a1 Explicitly mention that "cp -p" copies ACLs.
PR:		docs/168962
MFC after:	1 month
2012-09-04 12:27:23 +00:00
Edward Tomasz Napierala
6e924edbde Fix an error in setfacl(1) that manifested like this:
# setfacl -m u:trasz:rwx x
# setfacl -m u:root:rwx x
# getfacl x
# file: x
# owner: root
# group: wheel
user::rw-
user:root:rwx
user:trasz:rwx
group::r--
mask::rwx
other::r--
# setfacl -m u:root:rwx x
setfacl: x: acl_calc_mask() failed: Invalid argument
setfacl: x: failed to set ACL mask

For NFSv4 ACLs, this sort of situation would result in duplicated
entries.

MFC after:	1 month
2012-09-04 12:19:34 +00:00
Edward Tomasz Napierala
e99fc4b0f8 In getfacl(1) manual page, mention where to read about the ACL syntax.
PR submitter suggested adding it to acl(3) instead, but I don't think
pointing ordinary users at section 3 is a good idea.

PR:		docs/162380
MFC after:	1 month
2012-09-04 12:02:23 +00:00
Edward Tomasz Napierala
8ed068d31c Make "setfacl -bd" an alias for "setfacl -k". Previously it would crash
on assert.

PR:		bin/165807
MFC after:	1 month
2012-09-04 11:50:13 +00:00
Edward Tomasz Napierala
00b2b3a55d Make setfacl(1) behave properly in situations like "setfacl -kd".
MFC after:	1 month
2012-09-04 11:43:00 +00:00
Edward Tomasz Napierala
9828700277 Fix compact form of "synchronize" permission in setfacl(1) manual page - it
should be "s", not "S".

PR:		docs/162380
MFC after:	2 weeks
2012-09-03 17:26:20 +00:00
Ed Schouten
902d9eafbf Rework all non-contributed files that use `struct timezone'.
This structure is not part of POSIX. According to POSIX, gettimeofday()
has the following prototype:

	int gettimeofday(struct timeval *restrict tp, void *restrict tzp);

Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is
not used). Remove dead error handling code. Also use NULL for a
nul-pointer instead of integer 0.

While there, change all pieces of code that only use tv_sec to use
time(3), as this provides less overhead.
2012-09-01 14:45:15 +00:00
John Baldwin
6ce6b6c1d4 Add a -h flag similar to the -h flag for ln to force mv(1) to treat a
symbolic link to a directory for the target as a symbolic link instead of
a directory.  This makes it possible to atomically update a symbolic
link using rename().

Reviewed by:	gj
MFC after:	2 weeks
2012-08-31 14:35:01 +00:00
Ed Maste
4285666880 Avoid passing uninitialized stack to addelem() if called with an empty arg.
PR:		bin/171174
2012-08-29 21:38:34 +00:00
Jilles Tjoelker
1794251add sh: Fix EINTR race condition in "wait" and "set -T" using sigsuspend().
When waiting for child processes using "wait" or if "set -T" is in effect, a
signal interrupts the wait. Make sure there is no window where the signal
handler may be invoked (setting a flag) just before going to sleep.

There is a similar race condition in the shell language, but scripts can
avoid it by exiting from the trap handler or enforcing synchronization using
a fifo.

If SIGCHLD is not trapped, a signal handler must be installed for it. Only
install this handler for the duration of the wait to avoid triggering
unexpected [EINTR] errors elsewhere.

Note that for some reason only SIGINT and SIGQUIT interrupt a "wait"
command. This remains the case.
2012-07-29 18:04:38 +00:00
Jilles Tjoelker
fb05913c5d sh: Do not ask for stopped/continued processes if we do not need them
rather than retrying wait3 if they happen.
2012-07-28 15:13:48 +00:00
Jilles Tjoelker
61fb716ac9 sh: Inline waitproc() into its only caller. 2012-07-28 14:56:50 +00:00
Jilles Tjoelker
faa787d323 sh: Track continued jobs (even if not continued by bg or fg).
This uses wait3's WCONTINUED flag.

There is no message for this. The change is visible in "jobs" or if the job
stops again.
2012-07-28 14:32:55 +00:00
Jaakko Heinonen
e3481b298a Use proper error message when fstat(2) fails on stdout.
PR:		bin/159746
Submitted by:	Alex K.
2012-07-20 08:33:23 +00:00
Jaakko Heinonen
67bf019b10 style(9). 2012-07-20 08:31:36 +00:00
Jilles Tjoelker
989006abe5 stty: Mark usage() __dead2.
This reduces code size a little and should fix a scan-build warning.
2012-07-15 21:12:22 +00:00
Jilles Tjoelker
2aff415a8c ps: Fix memory leak when showing start/lstart for swapped-out process.
Spotted by:	scan-build (uqs)
2012-07-15 15:22:13 +00:00
Jilles Tjoelker
fa7ccda2c4 sh: Reset pendingsigs before checking pending traps, not after.
Otherwise, a signal arriving at exactly the right moment might not be
processed until another signal arrived.
2012-07-15 11:18:52 +00:00
Jilles Tjoelker
184dcee217 sh: Remove unused variable in_dowait. 2012-07-15 10:49:16 +00:00
Jilles Tjoelker
84fbdd8ca0 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
2012-07-15 10:19:43 +00:00
Pedro F. Giffuni
00c43e0ca4 Merge libedit adjustment from NetBSD.
On recent versions of NetBSD's libedit, el_gets
now sets el_len to -1 on error so we can
distinguish between a NULL string and an error.

This fixes sh from exiting with newer versions
of libedit now allowing EINTR to return.

Obtained from:	NetBSD
Reviewed by:	jilles
MFC after:	3 weeks
2012-07-11 22:17:58 +00:00
Xin LI
930e323894 Polish previous revision: if the fts_* routines have lstat()'ed the
directory entry then use the struct stat from that instead of doing
it again, and skip the rm_overwrite() call if fts_read() indicated
that the entry couldn't be a regular file.

Obtained from:	OpenBSD
MFC after:	1 week
2012-06-20 21:10:38 +00:00
Kevin Lo
4ec1405b39 Fix potential symlink race condition in "rm -P" by adding a check
that the file we have opened is the one we expected.  Also open in
non-blocking mode to avoid a potential hang with FIFOs.

Obtained from:	NetBSD via OpenBSD
2012-06-20 02:21:53 +00:00
Dag-Erling Smørgrav
7aa2051e40 None of these programs actually use auth.conf.
MFC after:	1 week
2012-06-11 16:18:39 +00:00
Marcel Moolenaar
937b0a997b Work better with how make/bmake works:
1.  Avoid a cd back into ${.CURDIR} to run mkbuiltins when we know make
    will first cd into ${.OBJDIR}. Keep the cwd to what make sets it to.
2.  Don't tell mkbuiltins where to write to (= ${.OBJDIR}), but where to
    get sources from (= ${.CURDIR}). This to compensate for point 1.

This fixes a problem with bmake's mk files that optimize ${.OBJDIR} to
expand to "." after changing cwd, not taking into account that the
target is pretty much undoing that and not getting the full path to the
object tree anymore.
2012-05-24 19:48:15 +00:00
Konstantin Belousov
4f1e1f86a1 Add 'cow' keyword to show per-process cow count.
Submitted by:	Andrey Zonov <andrey zonov org>
MFC after:	1 week
2012-05-23 18:11:36 +00:00
Warren Block
7b9da80729 Mention the upper hard limit for -n option. Patch slightly modified
from PR version.

PR:		168255
Submitted by:	Andy Kosela
Approved by:	gjb
MFC after:	3 days
2012-05-23 16:19:19 +00:00
Kevin Lo
fcae0e3887 Remove redundant declaration of yyparse
Reported by:	tinderbox
2012-05-22 03:01:54 +00:00
Marcel Moolenaar
6663ff446e Add build opton MK_LS_COLORS to control whether ls(1) supports colors
(and thus needs to depend on libtermcap). Embedded systems may not
want or need colors.

Obtained from:	Juniper Networks, Inc.
2012-05-19 18:05:00 +00:00
Marcel Moolenaar
aa39c44746 Add build option MK_ED_CRYPTO to control whether ed(1) is to have the
ability to encrypt/decrypt files. Embedded systems can typically have
OpenSSL, but not for ed(1) to use it.

Obtained from:	Juniper Networks, Inc.
2012-05-19 17:55:49 +00:00
Marcel Moolenaar
e7b903bf3d Remove unused header (libutil.h) 2012-05-17 20:29:15 +00:00
Jilles Tjoelker
ad859ed8cf sh: Remove an unused header.
The read builtin no longer does things with termios.
2012-05-15 22:50:47 +00:00
Joel Dahl
35471bf8ef Minor mdoc nits. 2012-05-13 14:16:04 +00:00
Matthew D Fleming
64afb51ccd I forgot to bump the manpage date.
Reminded by:	Garrett Cooper
MFC after:	3 days
X-MFC-with:	r235297
2012-05-12 02:49:40 +00:00
Matthew D Fleming
af68c71a5e Add a -v and -N option to kenv(1), so it can be more easily used in
scripts the way sysctl(8) is.  The -N option, like in sysctl(8),
displays only the kenv names, not their values.  The -v option prints an
individual kenv variable name with its value as name="value".  This is
the inverse of sysctl(8)'s -n flag, since the default behaviour of
kenv(1) is already like sysctl(8) -n.

Submitted by:	Garrett Cooper < yanegomi AT gmail DOT com >
MFC after:	1 week
2012-05-11 23:05:14 +00:00
Joel Dahl
748611c9c0 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
2012-04-07 09:05:30 +00:00
Jilles Tjoelker
b95fca474d sh: Fix build with -DDEBUG=2.
Reported by:	Kristof Provost
MFC after:	1 week
2012-04-02 17:16:24 +00:00
Joel Dahl
288eac5aed mandoc complains loudly when <TAB>s are misused in columnated lists. Fix
this syntax violation and while I'm here also convert <TAB> to Ta and adjust
quotation marks in order to prevent this problem in the future.
2012-03-29 16:02:40 +00:00
Eitan Adler
50d675f7a9 Remove trailing whitespace per mdoc lint warning
Disussed with:	gavin
No objection from:	doc
Approved by:	joel
MFC after:	3 days
2012-03-29 05:02:12 +00:00
Joel Dahl
904d0726c8 Remove superfluous paragraph macro. 2012-03-25 09:20:14 +00:00
Eitan Adler
8c3bbba824 rm[0].rm_so must be zero (an explicit check is made for zero in the
outer if condition)

Reviewed by:	se
Approved by:	cperciva
2012-03-19 00:45:01 +00:00
Konstantin Belousov
28c84226e8 Document P_ORPHAN.
MFC after:	3 days
2012-03-08 13:00:49 +00:00
Eitan Adler
45b586acc4 Bump date to today (since I modified it)
PR:		bin/165321
Approved by:	gjb
MFC after:	3 days
2012-03-03 17:52:19 +00:00
Eitan Adler
2561992179 Direct users to swapinfo and pstat from df
PR:		bin/165321
Submitted by:	jhs
Approved by:	bcr
MFC after:	3 days
2012-03-03 15:38:01 +00:00
Glen Barber
9d496f5ab6 Whitespace cleanup:
o Wrap sentences on to new lines
 o Cleanup trailing whitespace

Found with:	textproc/igor
MFC after:	1 week
X-MFC-With:	r232157
2012-02-25 15:21:43 +00:00
Glen Barber
3102cfe2e2 Fix various typos in manual pages.
Submitted by:	amdmi3
PR:		165431
MFC after:	1 week
2012-02-25 14:31:25 +00:00
Mark Peek
9ccc37e320 Update to tcsh 6.18.01. 2012-02-22 03:36:15 +00:00
Jilles Tjoelker
c0b3cf0676 sh: Make 'hash' return 1 if at least one utility is not found.
Reported by:	lme
2012-02-11 21:06:45 +00:00
Jilles Tjoelker
33233ec76e sh: Fix swapped INTON/INTOFF.
A possible consequence of this bug was a memory leak if SIGINT arrived
during a 'set' command (listing variables).

MFC after:	1 week
2012-02-04 23:29:07 +00:00
Jilles Tjoelker
caf29fab8c sh: Use vfork in a few common cases.
This uses vfork() for simple commands and command substitutions containing a
single simple command, invoking an external program under certain conditions
(no redirections or variable assignments, non-interactive shell, no job
control). These restrictions limit the amount of code executed in a vforked
child.

There is a large speedup (for example 35%) in microbenchmarks. The
difference in buildkernel is smaller (for example 0.5%) but still
statistically significant. See
http://lists.freebsd.org/pipermail/freebsd-hackers/2012-January/037581.html
for some numbers.

The use of vfork() can be disabled by setting a variable named
SH_DISABLE_VFORK.
2012-02-04 23:12:14 +00:00
Philippe Charnier
2fae4c3d95 Add prototypes, ANSIfy functions definitions to reduce WARNS=6 output. 2012-01-25 08:42:19 +00:00
Jilles Tjoelker
6eff4a75d5 sh: Fix $? in the first command of a 'for'.
In the first command of a 'for', $? should be the exit status of the last
pipeline (command substitution in the word list or command before 'for'),
not always 0.
2012-01-22 14:00:33 +00:00
Jilles Tjoelker
0105d7224d sh: Remove "kill" example function, which is superseded by the kill builtin
MFC after:	1 week
2012-01-21 20:39:17 +00:00
Ed Schouten
6aed20fe1a Remove unused variables.
Simply annotate the function parameters with __unused, instead of adding
the ve-variables. This makes the code build with GCC 4.7 and -Werror.
2012-01-17 22:17:10 +00:00
Jean-Sébastien Pédron
01a43bcf7b sh: Fix execution of multiple statements in a trap when evalskip is set
Before this fix, only the first statement of the trap was executed if
evalskip was set. This is for example the case when:
    o  "-e" is set for this shell
    o  a trap is set on EXIT
    o  a function returns 1 and causes the script to abort

Reviewed by:	jilles
MFC after:	2 weeks
2012-01-16 11:07:46 +00:00
Jilles Tjoelker
93fcb2511b sh: Fix some bugs with exit status from case containing ;&.
Also, rework evalcase() to not evaluate any tree. Instead, return the
NCLISTFALLTHRU node and handle it in evaltree().

Fixed bugs:

* If a ;& list with non-zero exit status is followed by an empty ;; or final
  list, the exit status of the case command should be equal to the exit
  status of the ;& list, not 0.

* An empty ;& case should not reset $?.
2012-01-15 21:39:38 +00:00
Jilles Tjoelker
92371efca2 sh: Fix two bugs with case and exit status:
* If no pattern is matched, POSIX says the exit status shall be 0 (even if
  there are command substitutions).
* If a pattern is matched and there are no command substitutions, the first
  command should see the $? from before the case command, not always 0.
2012-01-15 20:04:05 +00:00
Jilles Tjoelker
7f40c1f876 sh: Change input buffer size from 1023 to 1024.
PR:		bin/161756
2012-01-14 22:46:18 +00:00
Jilles Tjoelker
52c450395a sh: Fix out of bounds array access when trap is used with an invalid signal.
MFC after:	1 week
2012-01-14 21:54:12 +00:00
Jilles Tjoelker
e94e3511bd sh: Properly show "Not a directory" error in cd builtin.
The errno message display added in r222292 did not take attempting to
cd to a non-directory or something that cannot be stat()ed into account.

PR:		bin/164070
MFC after:	10 days
2012-01-13 23:32:27 +00:00
Ulrich Spörlein
38494eff98 Spelling fixes for bin/ 2012-01-07 16:10:23 +00:00
Jilles Tjoelker
260fc3f4d2 sh: Make various functions static. 2012-01-01 22:17:12 +00:00
Jilles Tjoelker
f6d3a9b03f sh: Remove unused function scopyn(). 2012-01-01 22:15:38 +00:00
Jilles Tjoelker
820491f824 sh: Make patmatch() non-recursive. 2012-01-01 20:50:19 +00:00
Jilles Tjoelker
3a1b9c9e82 sh: Allow quoting ^ and ] in bracket expressions. 2011-12-28 23:51:17 +00:00
Jilles Tjoelker
6e8db49a44 sh: Use dirent.d_type in pathname generation.
This improves performance for globs where a slash or another component
follows a component with metacharacters by eliminating unnecessary attempts
to open directories that are not.
2011-12-28 23:40:46 +00:00
Jilles Tjoelker
7a2b9d4b38 sh: Cache de->d_namlen in a local variable. 2011-12-28 23:30:17 +00:00
Jilles Tjoelker
a82f5687bf sh: Do not force special builtins non-special in optimized command subst.
This is not necessary: errors are already caught in evalbackcmd() and
forcelocal handles changes to variables.

Note that this depends on r223024.

MFC after:	4 weeks
2011-12-28 22:10:12 +00:00
Dimitry Andric
4bfc2007ab Fix some obtuse fprintf tricks in bin/ed.
MFC after:	1 week
2011-12-16 21:12:23 +00:00
Ed Schouten
469743871e Add static keywords to chio(1).
All other global variables are already marked static, so for consistency
sake, add them to these three arrays as well.
2011-12-11 20:53:12 +00:00
Ed Schouten
7b44b80961 Move 3.5 KB from the data segment to the text segment.
The `struct modes' are only used by the getter-functions in the same
file, so we can safely mark them static and const.
2011-12-11 09:56:48 +00:00
Jilles Tjoelker
03f33e912d sh: Remove impossible evalskip check in 'for'. 2011-11-27 00:09:59 +00:00
Jilles Tjoelker
a157dc4d90 sh: Reduce one level of evaltree() recursion when executing 'case'.
Free expanded case text before executing commands.
Remove impossible evalskip checks (expanding an argument cannot set
evalskip anymore since $(break) and the like are properly executed in a
subshell environment).
2011-11-26 23:28:31 +00:00
Jilles Tjoelker
ba22f6c693 test: Reduce code size of ops table. 2011-11-25 23:45:29 +00:00
Mikolaj Golub
6edf5accb6 Remove yet another outdated note about procfs(5) being required.
Spotted by:	arundel
2011-11-22 21:53:06 +00:00
Mikolaj Golub
57c87bfabb No need in procfs(5).
MFC after:	2 weeks
2011-11-22 21:14:46 +00:00
Jilles Tjoelker
bf3db314f7 sh: Allow unsetting OPTIND.
Note that only assigning the decimal value 1 resets getopts, as before.
2011-11-20 21:48:50 +00:00
Jilles Tjoelker
876f9b7800 sh: Remove undefined behaviour due to overflow in +/-/* in arithmetic.
With i386 base gcc and i386 base clang, arith_yacc.o remains unchanged.
2011-11-08 23:54:39 +00:00
Jilles Tjoelker
ad56ebdc15 sh(1): Improve documentation of field splitting. 2011-11-05 21:56:45 +00:00
Ed Schouten
f9d4afb439 Put some static keywords in the source code.
For these simple utilities, it doesn't harm to make all global variables
static. In fact, this allows the compiler to perform better forms of
optimisation and analysis.
2011-10-31 08:59:17 +00:00
Edward Tomasz Napierala
aa7a15b6bb For processes with no controlling terminal, display "-" in the TTY column
instead of "?".

Submitted by:	arundel
2011-10-30 15:21:27 +00:00
Dag-Erling Smørgrav
4d4dcc7aef If ls was invoked with -i but neither -l nor -s, blocksize was used in
display() to calculate column widths, but was not initialized in
main().  This resulted in a division by zero.

Noticed by:	Michael Butler <imb@protected-networks.net>
2011-10-19 15:35:41 +00:00
Dag-Erling Smørgrav
cf1479392e When calculating the width of the blocksize column, ls(1) used 512-byte
units (as returned by stat(2)) instead of BLOCKSIZE units.

Submitted by:	Paul Schenkeveld
MFC after:	3 weeks
2011-10-18 13:10:46 +00:00
Dag-Erling Smørgrav
16352ac84a Minor clarification
MFC after:	3 weeks
2011-10-18 08:20:36 +00:00
Dag-Erling Smørgrav
7b0514fa02 Simplify df(1) by factoring out most of the common code:
- In the argc == 0 case, just populate the mount list as before, but
   do not calculate widths, update totals or print anything.

 - In the argv > 0 case, collect information about the requested file
   systems and store it in the mount list, but do not calculate
   widths, update totals or print anything.

 - In either case, once all the information has been collected,
   iterate once through the mount list to calculate widths and totals,
   then once more to print everything.

This also fixes two bugs: firstly, column widths were not calculated
correctly if more than one file system was specified on the command
line; and secondly, file systems with MNT_IGNORE were included in the
totals even if -a was not specified.

Noticed by:	Paul Schenkeveld
MFC after:	3 weeks
2011-10-18 08:18:26 +00:00
Ivan Voras
a23ffe9673 Don't chop IO into small pieces, follow cp(1) and just use MAXPHYS. 2011-10-03 21:48:10 +00:00
Glen Barber
6ec3cd078c Correct a typo that was introduced in 225912
Submitted by:		Valentin Nechayev (netch % netch!kiev!ua), arundel
MFC after:		1 week
With-MFC:		225908
2011-10-02 16:05:19 +00:00
Glen Barber
2d455a01bd Tweaks to ps(1):
- there's no reason the semantics of the -x flag are being explained in
  the -a flag description
- be more precise regarding the relation between the -a flag and the
  security.bsd.see_other_uids sysctl
- describe the format of the -t flag's argument
- 'con' no longer is a possible entry in the 'TT' column
- explain that the 'TT' column refers to pseudo-terminals via mere numbers
- add a hint in the 'tt' keyword description that a keyword 'tty' exists,
  which will give the full terminal pathname

Submitted by:		arundel (via docs@) (original)
MFC after:		1 week
With-MFC:		225908
2011-10-01 23:47:37 +00:00
Glen Barber
6401543842 Reorder default ps(1) output according to reality.
Submitted by:	arundel (via docs@)
MFC after:	1 week
2011-10-01 20:56:58 +00:00
Edward Tomasz Napierala
1d1143ec27 Make ps(1) automatically size its column widths. 2011-09-29 06:31:42 +00:00
Ed Schouten
9f365aa1d6 Get rid of major/minor number distinction.
As of FreeBSD 6, devices can only be opened through devfs. These device
nodes don't have major and minor numbers anymore. The st_rdev field in
struct stat is simply based a copy of st_ino.

Simply display device numbers as hexadecimal, using "%#jx". This is
allowed by POSIX, since it explicitly states things like the following
(example taken from ls(1)):

	"If the file is a character special or block special file, the
	size of the file may be replaced with implementation-defined
	information associated with the device in question."

This makes the output of these commands more compact. For example, ls(1)
now uses approximately four columns less. While there, simplify the
column length calculation from ls(1) by calling snprintf() with a NULL
buffer.

Don't be afraid; if needed one can still obtain individual major/minor
numbers using stat(1).
2011-09-28 18:53:36 +00:00
Christian Brueffer
ae568477e7 Fix memory leaks in error cases.
PR:		159011
Submitted by:	Henning Petersen <henning.petersen@t-online.de>
Approved by:	re (kib)
MFC after:	1 week
2011-08-27 15:28:57 +00:00
Bjoern A. Zeeb
925af54487 Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.
Provide backward compatibility defines under BURN_BRIDGES.

Suggested by:	jhb
Reviewed by:	emaste
Sponsored by:	Sandvine Incorporated
Approved by:	re (kib)
2011-07-18 20:06:15 +00:00
Jilles Tjoelker
51a514adf2 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.
2011-07-10 15:02:25 +00:00
Stefan Eßer
69759f0829 Fix style, since this file has just been touched in a major way.
No actual code changes.
2011-07-09 12:20:15 +00:00
Stefan Eßer
6fbe7bf4f2 Some refactoring for easier maintenance of the code. This is a follow-up
to re-establishment of 64bit arithmetic, but is committed separately, to
not obscure that conversion. This commit does not change the observed
behaviour of expr in any way. Style will be fixed in a follow-up commit.
2011-07-09 12:14:57 +00:00
Stefan Eßer
fa717604a4 Make /bin/expr support 64bit numeric range and range checks by default,
again. This brings back the behaviour of expr in FreeBSD-4, which had been
reverted due to an assumed incompatbility with POSIX.1 for FreeBSD-5.

This issue has been discussed in the freebsd-standards list, and the
consensus was, that POSIX.1 is in fact not violated by this extension,
since it affects only cases of POSIX undefined behaviour (overflow of
signed long).

Other operating systems did upgrade their versions of expr to support
64bit range, after it had been initially brought to FreeBSD. They have
used it for a decade without problems, meanwhile.

The -e option is retained, but it will only select less strict checking
of numeric parameters (leading white-space, leading "+" are allowed and
skipped, an empty string is considered to represent 0 in numeric context.)
The call of check_utility_compat() as a means of establishing backwards
compatibility with FreeBSD-4 is considered obsolete, but preserved in
this commit. It is expected to be removed in a later revision of this
file.
Reviewed by:	bde, das, jilles
MFC after:	2 month (those parts that do not violate POLA)
2011-07-09 12:05:53 +00:00