Commit Graph

3256 Commits

Author SHA1 Message Date
Jilles Tjoelker
4445af212c sh: Add details about importing the environment and initializing OPTIND. 2015-02-22 21:32:57 +00:00
Enji Cooper
7a2065efd7 Disguising stderr from jls generally considered harmful
Undisguising it dumps out the following logspew:

jls: unknown parameter: allow

PR: 191019
2015-02-21 23:39:43 +00:00
Jilles Tjoelker
e63db0d3e5 symlink(7): Mention chflagsat() (can take AT_SYMLINK_NOFOLLOW).
MFC after:	1 week
2015-02-16 12:56:55 +00:00
Jilles Tjoelker
7034d8df04 sh: Various cleanups to expand.c:
* Remove some gotos.
* Remove unused parameter.
* Remove duplicate code.
2015-02-15 22:38:00 +00:00
Jilles Tjoelker
781bfb5a53 sh: Prefer "" to nullstr where possible. 2015-02-15 21:47:43 +00:00
Jilles Tjoelker
a4652c280b sh: Add stsavestr(), like savestr() but allocates using stalloc(). 2015-02-15 21:41:29 +00:00
Jilles Tjoelker
8c6cc7dad5 sh: Add simple tests for globbing/splitting command substitution. 2015-02-15 19:48:29 +00:00
Enji Cooper
bacc28cea1 Refactor pkill-j_test to reflect the relevant changes done to pgrep-j_test
r278742:

Simplify jail_name_to_jid and try to be more fault tolerant when scanning for
the jail ID (poll up to 10 times for the jail IDs to become available)

If the scan fails, the code will fall through and fail as it does with Jenkins
today

r278636:

Parameterize out the amount of sleep done in each test

Set the value in each test to a different amount to avoid potential
side-effects with other instances of the test (or lingering processes) still
being present on the system

r278633:

Refactor the tests

1. `id -u` -> 0 is now only checked once; the entire test script is now skipped
   if this assertion is violated
2. De-dent whitespace, based on 1.
3. Only setup the symlink for $sleep once at the top of the script, and tear it
   down once at the bottom of the script
2015-02-14 19:21:04 +00:00
Enji Cooper
8edd0e3040 Simplify jail_name_to_jid and try to be more fault tolerant when scanning for
the jail ID (poll up to 10 times for the jail IDs to become available)

If the scan fails, the code will fall through and fail as it does with Jenkins
today
2015-02-14 06:19:24 +00:00
Enji Cooper
01f66c0831 Call wait to ensure that background processes have died
This is being done to establish parity with pgrep-j_test
2015-02-13 01:07:12 +00:00
Enji Cooper
18f4d1079e Parameterize out the amount of sleep done in each test
Set the value in each test to a different amount to avoid potential
side-effects with other instances of the test (or lingering processes) still
being present on the system
2015-02-12 21:10:32 +00:00
Enji Cooper
b8b9865304 Refactor the tests
1. `id -u` -> 0 is now only checked once; the entire test script is now skipped
   if this assertion is violated
2. De-dent whitespace, based on 1.
3. Only setup the symlink for $sleep once at the top of the script, and tear it
   down once at the bottom of the script
2015-02-12 20:57:57 +00:00
Enji Cooper
24f1069ab4 Add debugging output to help track down the recent Jenkins failures 2015-02-12 07:22:46 +00:00
Pedro F. Giffuni
484f578134 Prevent access to an uninitialized variable
The "-h" option may access an uninitialized value. Prevent it
by properly initializing the value.

CID:	1006559
2015-01-31 15:41:01 +00:00
Jilles Tjoelker
edebe56497 sh: Abort a wait builtin on any trapped signal.
This is required by POSIX.

PR:		197210
Reported by:	ache
MFC after:	2 weeks
2015-01-31 13:53:29 +00:00
Stefan Eßer
8da97f0057 Fix overflow check for multiplication:
- Add special test to detect the case of -1 * INTMAX_MIN
- Protect against elimination of the test division by the optimizer

Garrett Cooper noticed that the overflow checks were incomplete, and Bruce
Evans suggested the use of the "volatile" qualifier to counter the effect
of the undefined behaviour, when the prior multiplication caused overflow,
and he also suggested improvements to the comments.

Reviewed by:	bde
MFC after:	1 week
2015-01-27 18:04:41 +00:00
Jilles Tjoelker
5faf2ae160 cp,mv,touch: Set timestamps with nanosecond precision.
This uses utimensat().
2015-01-24 13:50:13 +00:00
Jilles Tjoelker
2205e0d1bd Add futimens and utimensat system calls.
The core kernel part is patch file utimes.2008.4.diff from
pluknet@FreeBSD.org. I updated the code for API changes, added the manual
page and added compatibility code for old kernels. There is also audit and
Capsicum support.

A new UTIME_* constant might allow setting birthtimes in future.

Differential Revision:	https://reviews.freebsd.org/D1426
Submitted by:	pluknet (partially)
Reviewed by:	delphij, pluknet, rwatson
Relnotes:	yes
2015-01-23 21:07:08 +00:00
Hajimu UMEMOTO
f79998c8fc Don't include newvers.sh into freebsd-version. 2015-01-22 17:13:43 +00:00
Enji Cooper
e15138e574 Integrate contrib/netbsd-tests/bin/expr into the build/kyua as bin/expr/tests
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-01-19 06:13:07 +00:00
Will Andrews
7a37b5fc17 Add a ${CP} alias for copying files in the build.
Some users build FreeBSD as non-root in Perforce workspaces.  By default,
Perforce sets files read-only unless they're explicitly being edited.
As a result, the -f argument must be used to cp in order to override the
read-only flag when copying source files to object directories.  Bare use of
'cp' should be avoided in the future.

Update all current users of 'cp' in the src tree.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Spectra Logic
2015-01-16 21:39:08 +00:00
Enji Cooper
a9c218da80 Install d_align.{in,out} for the :align test
X-MFC with: r276669
Pointyhat to: me
2015-01-05 20:38:47 +00:00
Enji Cooper
dd2b763aa5 Integrate bin/cat/tests from NetBSD into atf/kyua
Sponsored by: EMC / Isilon Storage Division
2015-01-04 22:37:44 +00:00
Jilles Tjoelker
df30ae985d symlink(7): Note that stat(1) does not follow symlinks by default.
MFC after:	1 week
2014-12-29 13:02:03 +00:00
Jilles Tjoelker
85052e7b56 sh: Move some code from onint() to onsig(), making onint() noreturn.
As a result, the INTON macro which is used many times generates fewer
bytes of code.
2014-12-21 23:09:59 +00:00
Jilles Tjoelker
f649ab8b15 sh: Remove EXP_REDIR.
EXP_REDIR was supposed to generate pathnames in redirection if exactly one
file matches, as permitted but not required by POSIX in interactive mode. It
is unlikely this will be implemented.

No functional change is intended.

MFC after:	1 week
2014-12-21 22:18:30 +00:00
Jilles Tjoelker
88ef06f3a9 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.
2014-12-14 16:26:19 +00:00
Konstantin Belousov
6ddcc23386 Add facility to stop all userspace processes. The supposed use of the
feature is to quisce the system before suspend.

Stop is implemented by reusing the thread_single(9) with the special
mode SINGLE_ALLPROC.  SINGLE_ALLPROC differs from the existing
single-threading modes by allowing (requiring) caller to operate on
other process.  Interruptible sleeps for !TDF_SBDRY threads are
suspended like SIGSTOP does it, instead of aborting the sleep, like
SINGLE_NO_EXIT, to avoid spurious EINTRs on resume.

Provide debugging sysctl debug.stop_all_proc, which causes total stop
and suspends syncer, while waiting for variable reset for resume.  It
is used for debugging; should be removed after the real use of the
interface is added.

In collaboration with:	pho
Discussed with:	avg
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2014-12-13 16:18:29 +00:00
Dag-Erling Smørgrav
cb92abb49c Fix dependency on newvers.sh
Noticed by:	marck
MFC after:	1 week
2014-12-10 03:12:22 +00:00
Jilles Tjoelker
e753a1effb 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.
2014-11-30 20:12:47 +00:00
Baptiste Daroussin
12cd1730ee Convert bin/ to LIBADD, reduce overlinking allow to build all components as
static
2014-11-25 11:15:40 +00:00
Jilles Tjoelker
fafeab4393 sh: Prepend "$0: " to error messages if there is no command name. 2014-11-22 23:28:41 +00:00
Jilles Tjoelker
08dc8cf90c sh: Use DQSYNTAX only while expanding, not SQSYNTAX.
Quoting during expansion only cares about CCTL, which is the same for
DQSYNTAX and SQSYNTAX.
2014-11-22 16:03:18 +00:00
Simon J. Gerraty
488c975a1f Updated/new dependencies 2014-11-19 07:10:38 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Jilles Tjoelker
b1f6059232 sh(1): Add/improve information about exit status of commands. 2014-11-14 17:11:28 +00:00
Jilles Tjoelker
945e15624b 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).
2014-11-07 21:30:16 +00:00
Marcel Moolenaar
6fea8dc88f Document that df(1) supports libxo(3). 2014-11-07 03:07:10 +00:00
Marcel Moolenaar
b6ff8745aa Convert to use libxo.
Obtained from:  Phil Shafer <phil@juniper.net>
Sponsored by:   Juniper Networks, Inc.
2014-11-07 03:03:25 +00:00
Jilles Tjoelker
5dff1efc27 sh: Fix corruption of CTL* bytes in positional parameters in redirection.
EXP_REDIR was not being checked for while expanding positional parameters in
redirection, so CTL* bytes were not being prefixed where they should be.

MFC after:	1 week
2014-10-31 22:28:10 +00:00
Jilles Tjoelker
3fb51b3a43 Treat IFS separators in "$*" as quoted.
This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
2014-10-28 22:14:31 +00:00
Kurt Jaeger
f4cfd28bb5 bin/dd: revert 273734, as it fails on 32bit platforms
Revert: insufficient testing on 32bit platforms

PR:		191263
2014-10-27 17:39:37 +00:00
Kurt Jaeger
179eb7112b bin/dd: Fix incorrect casting of arguments
dd(1) casts many of its numeric arguments from uintmax_t to intmax_t
and back again to detect whether or not the original arguments were
negative. This caused wrong behaviour in some boundary cases:

$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count cannot be negative

After the fix:

$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count: Result too large

PR:		191263
Submitted by:	will@worrbase.com
Approved by:	cognet@
2014-10-27 11:38:17 +00:00
Jilles Tjoelker
1bc2fdfabf sh: Make getopts memory-safe if with changing arguments.
POSIX does not permit to continuing a getopts loop with different
arguments. For parsing the positional parameters, we handle this case by
resetting the getopts state when the positional parameters are changed in
any way (and the getopts state is local to a function). However, in the
syntax getopts <optstring> <var> <arg...>, changes could lead to invalid
memory access.

In the syntax getopts <optstring> <var> <arg...>, store a copy of the
arguments and continue to use them until getopts is reset.
2014-10-26 17:50:33 +00:00
Jilles Tjoelker
0b4b9c8158 sh: Allow backslash-newline continuation in more places:
* directly after a $
 * directly after ${
 * between the characters of a multi-character operator token
 * within a parameter name
2014-10-19 11:59:15 +00:00
Jilles Tjoelker
334111e2df sh: Add some tests for backslash-newline continuation. 2014-10-17 21:52:57 +00:00
Jilles Tjoelker
3f9b4e9ab8 sh: Make parseredir() a proper function instead of an emulated nested
function.
2014-10-15 21:26:09 +00:00
Jilles Tjoelker
622fdf3236 sh: Remove more gotos. 2014-10-15 21:20:56 +00:00
Jilles Tjoelker
75e1716807 sh: Fix break/continue/return in multiline eval.
Example:
  eval $'return\necho bad'
2014-10-12 13:12:06 +00:00
Enji Cooper
6186fd1857 Integrate bin/sleep/tests from NetBSD into atf/kyua
Sponsored by: EMC / Isilon Storage Division
2014-10-09 01:39:07 +00:00
Jilles Tjoelker
33c5acf038 sh: Eliminate some gotos. 2014-10-05 21:51:36 +00:00
Jilles Tjoelker
068dfa2d43 sh: Fix LINENO and prompt after $'\0 and newline. 2014-10-03 20:24:56 +00:00
Craig Rodrigues
6677932e5d Fix pkill unit tests.
- use daemon(8) to write out a pid file for processes,
  and check for for the existence of that file after
  killing processes
- use explict named parameters to jail(8)
2014-09-30 15:27:49 +00:00
Jilles Tjoelker
000dda7b47 sh(1): Clarify that assignments before commands do not affect expansions.
PR:		193759
MFC after:	1 week
2014-09-21 20:34:54 +00:00
Will Andrews
76479f1d3f Fix incremental builds involving non-root users with read-only source files.
Makefiles should not assume that source files can be overwritten.  This is the
common case for Perforce source trees.

This is a followup commit to r211243 in the same vein.

MFC after:	1 month
Sponsored by:	Spectra Logic
MFSpectraBSD:	r1036319 on 2014/01/29, r1046711 on 2014/03/06
2014-09-18 14:41:57 +00:00
Jilles Tjoelker
72238faa6a sh: Remove arbitrary length limit on << EOF markers.
This also simplifies the code.
2014-09-14 16:46:30 +00:00
Jilles Tjoelker
671a890e58 sh: Make checkend() a real function instead of an emulated nested function.
No functional change is intended, but the generated code is slightly
different.
2014-09-14 16:27:49 +00:00
Jilles Tjoelker
5545fadd84 sh: Add some const keywords. 2014-09-14 15:59:15 +00:00
Jilles Tjoelker
cd60e2c67d 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.
2014-09-04 21:48:33 +00:00
Warner Losh
a83c9ec1e5 Update the date for last example.
Sponsored by: Netflix
2014-08-30 02:12:58 +00:00
Warner Losh
56fd128433 Add canonical population of a disk / thumb drive from an image
example.
2014-08-28 21:30:39 +00:00
Mateusz Guzik
8b04bbef31 Return real parent pid in kinfo (used by e.g. ps)
Add a separate field which exports tracer pid and add a new keyword
("tracer") for ps to display it.

This is a follow up to r270444.

Reviewed by:	kib
MFC after:	1 week
Relnotes:	yes
2014-08-28 08:41:11 +00:00
Pedro F. Giffuni
0fa46a4231 Always check the limits of array index variables before using them.
Obtained from:	DragonFlyBSD
MFC after:	1 week
2014-08-21 02:40:33 +00:00
Jilles Tjoelker
dd6d480a3e sh: Remove two redundant (uintmax_t) casts.
Submitted by:	jmallett
2014-08-20 20:15:43 +00:00
Bryan Drewery
5608fd23c2 Revert r267233 for now. PIE support needs to be reworked.
1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other
   build-only utility libraries.
2. Another 40% is fixed by generating _pic.a variants of various libraries.
3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR)
   where it never would work anyhow, such as csu or loader. This suggests
   there may be better ways of adding support to the tree. Many of these
   cases can be fixed such that -fPIE will work but there is really no
   reason to have it in those cases.
4. Some of the uses are working around hacks done to some Makefiles that are
   really building libraries but have been using bsd.prog.mk because the code
   is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have
   been needed.

We likely do want to enable PIE by default (opt-out) for non-tree consumers
(such as ports). For in-tree though we probably want to only enable PIE
(opt-in) for common attack targets such as remote service daemons and setuid
utilities. This is also a great performance compromise since ASLR is expected
to reduce performance. As such it does not make sense to enable it in all
utilities such as ls(1) that have little benefit to having it enabled.

Reported by:	kib
2014-08-19 15:04:32 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Jilles Tjoelker
ef9e61785a sh: Avoid overflow in atoi() when parsing HISTSIZE.
Side effect: a non-numeric HISTSIZE now results in the default size (100)
instead of 0.
2014-08-17 19:36:56 +00:00
Jilles Tjoelker
d53f7f64f7 sh: Reject integer overflow in number and is_number. 2014-08-17 16:40:29 +00:00
Jilles Tjoelker
1c9c6ea481 sh: Don't hardcode relative paths in the tests stderr files.
These paths have had to be adjusted to changes in the testsuite runner
several times, so modify the tests to remove the need for such adjustment.

A cp in functional_test.sh is now unneeded, but this matters little in
performance.
2014-08-17 14:26:12 +00:00
Jilles Tjoelker
d5b14891eb sh: Mask off shift distance (<< and >>) in arithmetic.
In C, shift distances equal to or larger than the number of bits in the
operand result in undefined behaviour. As part of eliminating undefined
behaviour in arithmetic, mask off the distance like Java and JavaScript
specify and C on x86 usually does.

Assumption: conversion from unsigned to signed retains the two's complement
bits.
Assumption: uintmax_t has no padding bits.
2014-08-15 22:36:41 +00:00
Alan Somers
da02ed7331 Skip pgrep-j and pkill-j if jail or jls is not installed.
Even though jail is part of the base system, it can be disabled by src.conf
settings. Therefore, it should be listed as a required program for tests
that use it.

CR:		D603
MFC after:	3 days
Sponsored by:	Spectra Logic
2014-08-14 14:59:40 +00:00
Enji Cooper
9f31240773 Port date/bin/tests to ATF
Phabric: D545
Approved by: jmmv (mentor)
Submitted by: keramida (earlier version)
MFC after: 2 weeks
Sponsored by: Google, Inc
Sponsored by: EMC / Isilon Storage Division
2014-08-13 04:43:29 +00:00
Enji Cooper
12e2df3c36 Convert bin/sh/tests to ATF
The new code uses a "test discovery mechanism" to determine
what tests are available for execution

The test shell can be specified via:

  kyua test -v test_suites.FreeBSD.bin.sh.test_shell=/path/to/test/sh

Sponsored by: EMC / Isilon Storage Division
Approved by: jmmv (mentor)
Reviewed by: jilles (maintainer)
2014-08-13 04:14:50 +00:00
Konstantin Belousov
d735998057 Correct the problems with the ptrace(2) making the debuggee an orphan.
One problem is inferior(9) looping due to the process tree becoming a
graph instead of tree if the parent is traced by child. Another issue
is due to the use of p_oppid to restore the original parent/child
relationship, because real parent could already exited and its pid
reused (noted by mjg).

Add the function proc_realparent(9), which calculates the parent for
given process. It uses the flag P_TREE_FIRST_ORPHAN to detect the head
element of the p_orphan list and than stepping back to its container
to find the parent process. If the parent has already exited, the
init(8) is returned.

Move the P_ORPHAN and the new helper flag from the p_flag* to new
p_treeflag field of struct proc, which is protected by proctree lock
instead of proc lock, since the orphans relationship is managed under
the proctree_lock already.

The remaining uses of p_oppid in ptrace(PT_DETACH) and process
reapping are replaced by proc_realparent(9).

Phabric:	D417
Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2014-08-07 05:47:53 +00:00
Jilles Tjoelker
4d34663be3 sh: Allow arbitrarily large numbers in break and continue.
The argument is capped to loopnest, so strtol()'s [ERANGE] can be ignored.
2014-07-20 20:29:09 +00:00
Jilles Tjoelker
e61ae4ffc8 sh: Remove prefix() function. Use strncmp() instead. 2014-07-20 12:06:52 +00:00
Jilles Tjoelker
2ef146f14c sh: Deduplicate some code in ulimit builtin. 2014-07-19 14:06:23 +00:00
Brooks Davis
80189b3b09 Replace all uses of libncurses and libtermcap with their wide character
variants.  This allows usable file system images (i.e. those with both a
shell and an editor) to be created with only one copy of the curses library.

Exp-run:	antoine
PR:		189842
Discussed with:	bapt
Sponsored by:	DARPA, AFRL
2014-07-17 18:24:34 +00:00
Jilles Tjoelker
7b9104c0a9 sh: Correctly handle positional parameters beyond INT_MAX on 64-bit systems.
Currently, there can be no more than INT_MAX positional parameters. Make
sure to treat all higher ones as unset to avoid incorrect results and
crashes.

On 64-bit systems, our atoi() takes the low 32 bits of the strtol() and
sign-extends them.

On 32-bit systems, the call to atoi() returned INT_MAX for too high values
and there is not enough address space for so many positional parameters, so
there was no issue.
2014-07-12 21:54:11 +00:00
Jilles Tjoelker
5ddabb8348 sh: Consistently treat ${01} like $1.
Leading zeroes were ignored when checking whether a positional parameter is
set, but not when expanding its value. Ignore leading zeroes in any case.
2014-07-12 10:27:30 +00:00
Jilles Tjoelker
f1058ba09a sh: Add test for ${01} and ${010} that already works.
Although it is probably unwise to use this, POSIX is clear that leading
zeroes are permitted in positional parameters (and do not indicate octal).

Such positional parameters are checked for being unset and/or null
correctly, but their value is incorrectly expanded.
2014-07-08 22:04:44 +00:00
Jilles Tjoelker
725d072732 Don't install locale1.0 if MK_NLS == no.
The test locale1.0 depends on locale support; it is meaningless without a
working LC_MESSAGES.

I added an OptionalObsoleteFiles.inc entry.

PR:		181151
Submitted by:	Garrett Cooper (original version)
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2014-07-08 21:50:13 +00:00
Warner Losh
413a368c90 rm -rf can fail sometimes with an error from fts_read. Make it honor
fflag to ignore fts_read errors, but stop deleting from that directory
because no further progress can be made.

When building a kernel with a high -j value on a high core count
machine, during the cleanobj phase we can wind up doing multiple rm
-rf at the same time for modules that have subdirectories. This
exposed this race (sometimes) as fts_read can return an error if the
directory is removed by another rm -rf. Since the intent of the -f
flag was to ignore errors, even if this was a bug in fts_read, we
should ignore the error like we've been instructed to do.
2014-07-07 23:21:20 +00:00
Jilles Tjoelker
2d70c63720 sh: Fix overflow checking on 'ulimit' operand. 2014-07-05 21:50:59 +00:00
Xin LI
c15455feb3 Check if fchflags() is needed by fstat'ing before and check
the results.

Reviewed by:	jilles
X-MFC-With:	r267977
2014-07-01 22:46:39 +00:00
Xin LI
e6683f19dd Always set UF_ARCHIVE on target (because they are by definition new files
and should be archived) and ignore error when we can't set it (e.g. NFS).

Reviewed by:	ken
MFC after:	2 weeks
2014-06-27 19:57:54 +00:00
Baptiste Daroussin
bd0891ceb3 use .Mt to mark up email addresses consistently (part1)
PR:		191174
Submitted by:	Franco Fichtner  <franco@lastsummer.de>
2014-06-20 09:40:43 +00:00
Joel Dahl
cf20d40493 mdoc: remove superfluous paragraph macros. 2014-06-15 10:43:12 +00:00
Bryan Drewery
864c53ead8 In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.
This is currently an opt-in build flag. Once ASLR support is ready and stable
it should changed to opt-out and be enabled by default along with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will be enabled by
default in new directories when the system is compiled with PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

The only known runtime failure was rtld.

[1] http://www.bsdcan.org/2014/schedule/events/452.en.html
Submitted by:		Shawn Webb <lattera@gmail.com>
Discussed between:	des@ and Shawn Webb [2]
2014-06-08 17:29:31 +00:00
Sergey Kandaurov
38d22923f7 Add support for inspecting process flags set in p_flag2.
Reviewed by:	jhb
MFC after:	1 week
2014-06-06 22:52:11 +00:00
Warner Losh
04efeffe99 When building picobsd, define WITHOUT_OPENSSL and WITHOUT_KERBEROS and
remove the now-redundant checks for RELEASE_CRUNCH. This originally
was defined for building smaller sysinstall images, but was later also
used by picobsd builds for a similar purpose. Now that we've moved
away from sysinstall, picobsd is the only remaining consumer of this
interface. Adding these two options reduces the RELEASE_CRUNCH
special cases in the tree by half.
2014-06-06 04:09:07 +00:00
Jilles Tjoelker
b0762e4921 sh: Avoid undefined behaviour shifting negative values left in arithmetic.
With i386 base clang, arith_yacc.o remains unchanged.
2014-06-01 11:25:34 +00:00
Jilles Tjoelker
2ceda70233 sh: Simplify find_command() slightly. 2014-05-31 22:25:45 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Jilles Tjoelker
c8fb3e69d0 sh: In getopts, unset OPTARG where POSIX says we should. 2014-05-10 19:18:49 +00:00
Jilles Tjoelker
8207fd5f81 sh: Add new tests to the Makefile. 2014-05-10 19:06:36 +00:00
Jilles Tjoelker
6e76445cf7 sh: Don't discard getopts state on unknown option or missing argument.
When getopts finds an invalid option or a missing option-argument, it should
not reset its state and should set OPTIND as normal. This is an old ash bug
that was fixed long ago in dash. Our behaviour now matches most other
shells.
2014-05-10 17:42:21 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Jilles Tjoelker
8c4e5fc061 sh: Send getopts error messages to stderr, not stdout.
Adjust a testcase for this change.
2014-05-09 13:32:36 +00:00
Jilles Tjoelker
bc7f6652dd sh: Add more necessary INTOFF/INTON. 2014-05-09 13:27:30 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Alan Somers
540c78258c Incorporate feedback from bde and jilles regarding r265472 to dd(1).
* Don't use sysexits.h.  Just exit 1 on error and 0 otherwise.
* Don't sacrifice precision by converting the output of clock_gettime() to a
  double and then comparing the results.  Instead, subtract the values of
  the two clock_gettime() calls, then convert to double.
* Don't use CLOCK_MONOTONIC_PRECISE.  It's an unportable synonym for
  CLOCK_MONOTONIC.
* Use more appropriate names for some local variables.
* In the summary message, round elapsed time to the nearest microsecond.

Reported by:	bde, jilles
MFC after:	3 days
X-MFC-With:	265472
2014-05-08 19:10:04 +00:00
Jilles Tjoelker
5699ef2588 sh: Add some tests for normal use of getopts. 2014-05-07 21:45:25 +00:00
Thomas Quinot
aa7a161b40 (dd_out): Fix handling of all-zeroes block at end of input with
conv=sparse.

This change fixes two separate issues observed when the last output
block is all zeroes, and conv=sparse is in use. In this case, care
must be taken to roll back the last seek and write the entire last zero
block at the original offset where it should have occurred: when the
destination file is a block device, it is not possible to roll back
by just one character as the write would then not be properly aligned.

Furthermore, the buffer used to write this last all-zeroes block
needs to be properly zeroed-out. This was not the case previously,
resulting in a junk data byte appearing instead of a zero in the
output stream.

PR:		bin/189174
PR:		bin/189284
Reviewed by:	kib
MFC after:	2 weeks
2014-05-07 19:33:29 +00:00
Alan Somers
d1d66eac15 dd(1) uses gettimeofday(2) to compute the throughput statistics. However,
gettimeofday returns the system clock, which may jump forward or back,
especially if NTP is in use.  If the time jumps backwards, then dd will see
negative elapsed time, round it up to 1usec, and print an absurdly fast
transfer rate.

The solution is to use clock_gettime(2) with CLOCK_MONOTONIC_PRECISE as the
clock_id.  That clock advances steadily, regardless of changes to the system
clock.

Reviewed by:	delphij
MFC after:	3 days
Sponsored by:	Spectra Logic
2014-05-06 22:06:39 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Thomas Quinot
37f1b88ba0 Minor comment fix: dbsz is the block size as set by bs/ibs/obs,
not the size of the buffer.
2014-05-03 09:07:02 +00:00
Thomas Quinot
66d5f71966 Minor comment fix. 2014-05-03 09:06:11 +00:00
Bryan Drewery
13767130c7 Add -J to filter by matching jail IDs and names.
-J 0 can be used to show only host processes.

Patch partially based on work by bz@

PR:		bin/78763
MFC after:	2 weeks
Relnotes:	yes
2014-05-02 15:05:47 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Jean-Sébastien Pédron
2fd66cdd22 date(1): Forgot to update manpage date in r264968
MFC after:	1 week
MFC with:	264968
2014-04-26 13:53:04 +00:00
Jean-Sébastien Pédron
b69ced8d8c date(1): Add "-R" flag to use RFC 2822 date and time output format
As stated in the man page, this is equivalent to use "%a, %d %b %Y %T %z"
as the output format while LC_TIME is set to the "C" locale.

This is compatible with date(1) from the GNU core utilities.
2014-04-26 13:05:56 +00:00
Glen Barber
cc444214a3 Bump Dd, missed as part of r264098 and related commits.
Sponsored by:	The FreeBSD Foundation
2014-04-13 01:47:15 +00:00
Greg Lehey
3490c30476 -k option is compliant with POSIX. 2014-04-04 01:48:25 +00:00
Greg Lehey
a50f6875f6 Typo.
Reported by: Igor Sobrado.
2014-04-03 23:22:04 +00:00
Xin LI
413ef2a3d1 Make C_* contants fit in 32 bits again by using 4 unused bits.
Noticed by:	bde
2014-04-03 06:32:02 +00:00
Greg Lehey
8f7aa283ab Add information on standards compliance of many options.
MFC after:	2 weeks
2014-04-03 05:49:28 +00:00
Greg Lehey
3651faa511 Make -f set -a, as required by the standard.
From the original OpenBSD commit message:

  restore the traditional behavior of -f implying -a; apparently Keith
  Bostic forgot to restore it when the -f flag was put back on 2nd of
  September 1989, after being removed on 16th of August as a
  consequence of issues getting it working over NFS, so deviation from
  traditional UNIX behavior in all BSDs looks like an historical
  accident; as a side effect, this change accommodates behavior of
  this option to IEEE Std 1003.1-2008 (``POSIX.1'').

  joint work with jmc@ (who found the inaccuracy in our
  implementation), schwarze@ (who provided a detailed tracking of
  historical facts) and millert@

Submitted by: Igor Sobrado
Discussed with:  mckusick
Obtained from: OpenBSD project
MFC after:  2 weeks
2014-04-03 05:48:28 +00:00
Xin LI
c3f5e9c515 Implement GNU's extension of 'status' operand. The GNU syntax is
borrowed where syntax status=noxfer means no transfer statistics
and status=none means no status information at all.

This feature is useful because the statistics information can
sometimes be annoying, and redirecting stderr to /dev/null would
mean error messages also gets silenced.

Obtained from:	OpenBSD
MFC after:	2 weeks
2014-04-03 00:55:16 +00:00
Jilles Tjoelker
d73dba75d6 sh: Fix memory leak with an assignment before a regular builtin.
MFC after:	1 week
2014-03-27 22:57:23 +00:00
Jilles Tjoelker
89d4f883a4 sh: Fix memory leak when trying to set a read only variable.
MFC after:	1 week
2014-03-27 22:52:26 +00:00
Dimitry Andric
54ff5d7323 Add a SUBDIR_PARALLEL option to bsd.subdir.mk, to allow make to process
all the SUBDIR entries in parallel, instead of serially.  Apply this
option to a selected number of Makefiles, which can greatly speed up the
build on multi-core machines, when using make -j.

This can be extended to more Makefiles later on, whenever they are
verified to work correctly with parallel building.

I tested this on a 24-core machine, with make -j48 buildworld (N = 6):

                before    stddev       after    stddev
                =======   ======       =======  ======
real time        1741.1     16.5         959.8     2.7
user time       12468.7     16.4       14393.0    16.8
sys  time        1825.0     54.8        2110.6    22.8

(user+sys)/real     8.2                   17.1

E.g. the build was approximately 45% faster in real time.  On machines
with less cores, or with lower -j settings, the speedup will not be as
impressive.  But at least you can now almost max out a machine with
buildworld!

Submitted by:	jilles
MFC after:	2 weeks
2014-03-26 22:30:38 +00:00
Jilles Tjoelker
1632bf1a88 sh: Fix possible memory leaks and double frees with unexpected SIGINT. 2014-03-26 20:43:40 +00:00
Jilles Tjoelker
728e552fdc sh: Don't overwrite old exit status if a PID is reused.
Only store exit status for a process if that process has not terminated yet.

Test (slow):
  exit 7 & p1=$!; until exit 8 & p2=$!; [ "$p1" = "$p2" ]; do wait "$p2";
  done; sleep 0.1; wait %1; echo $?
should write "7".
2014-03-20 22:38:13 +00:00
Julio Merino
65c3cfc1aa Migrate tools/regression/usr.bin/pkill to the new tests layout.
Interestingly, the pkill tool lives in bin, not usr.bin.  Haven't bothered
to check if this is because the tool moved or because the tests were
originally added in the wrong place.
2014-03-19 12:46:04 +00:00
Jilles Tjoelker
7696168706 sh: Allow kill %job on jobs started without job control.
When killing a %job started without job control, kill all processes in it.
As with process groups and zombies, if any process in the job can be killed
or has already terminated, the command is successful.

This also fixes occasional failures of the builtins/kill1.0 test.
2014-03-15 14:58:48 +00:00
Jilles Tjoelker
61346cbdc7 sh: Add some consts. 2014-03-14 21:45:37 +00:00
Julio Merino
f5fd950e35 Make bsd.test.mk the only public mk fragment for the building of tests.
Change {atf,plain,tap}.test.mk to be internal implementation details of
bsd.test.mk.  Makefiles that build tests should now only include bsd.test.mk
and declaratively specify what they want to build, without worrying about
the internal implementation of the mk files.

The reason for this change is to permit building test programs of different
interfaces from a single directory, which is something I had a need for
while porting tests over from src/tools/regression/.

Additionally, this change makes it possible to perform some other requested
changes to bsd.test.mk in an easier manner.  Coming soon.
2014-03-14 08:56:19 +00:00
Jilles Tjoelker
4646e82dcd sh: Successfully do nothing when killing a terminated job.
If a job has terminated but is still known, silently do nothing when using
the kill builtin with the job specifier. Formerly, the shell called kill()
with the process group ID that might have been reused.
2014-03-08 19:44:34 +00:00
Jilles Tjoelker
a2cba42fc2 sh: Make argstr() return where it stopped and simplify expari() using this. 2014-03-04 22:30:38 +00:00
Jilles Tjoelker
ce16da82dd sh: Simplify expari().
Redo expari() like evalvar(). This makes the logic more understandable and
avoids possible problems if arithmetic expansion occurs if CTLESC characters
are not generated (looking backwards for CTLARI is not generally possible in
that case but the old code tried anyway).

This adds an extra argstr() recursion.
2014-03-02 22:59:34 +00:00
Jilles Tjoelker
5439648913 sh: Do not corrupt internal representation if LINENO inner expansion fails.
Example:
  f() { : ${LINENO+$((1/0))}; }
and call this function twice.
2014-02-27 16:54:43 +00:00
Jilles Tjoelker
85bf1d2f07 sh: Make expari() static. 2014-02-26 21:38:42 +00:00
Daichi GOTO
455b654622 sh: Add -h option to SYNOPSIS
Reviewed by:	jilles
MFC after:	soon
2014-02-25 03:05:43 +00:00
Jilles Tjoelker
48f49aac53 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).
2014-01-26 21:19:33 +00:00
Kevin Lo
248825e568 Stop the options string leak if it is not attached into the options
linked list.

Obtained from:	OpenBSD
2014-01-26 07:20:32 +00:00
Jilles Tjoelker
03e55809f4 sh: Add tests for alias names after another alias.
Since the first alias's value does not end with a blank, the next word
should not be checked for aliases.
2014-01-25 14:59:08 +00:00
Jilles Tjoelker
3d132810d2 sh: Do not depend on parse/execute split in new alias test. 2014-01-24 23:00:35 +00:00
Jilles Tjoelker
4b489a60e1 sh: Solve the alias recursion problem in a less hackish way.
Add the space to avoid alias recursion when the alias is expanded, not when
it is added.

As a result, displaying an alias via command -v, command -V or type no
longer erroneously appends a space. Adjust the tests so they now require
this bug to be absent.
2014-01-24 16:40:51 +00:00
Jilles Tjoelker
981a0f19d3 sh: Add test for nested alias. 2014-01-24 15:03:56 +00:00
Warren Block
3a97f8af0d -h and -H options backwards in manual page.
PR:		bin/183681 docs/183681
Submitted by:	Robin Hahling <robin.hahling@gw-computing.net>
MFC after:	3 days
2014-01-16 17:06:02 +00:00
Jilles Tjoelker
d78fdfde89 sh: Remove SIGWINCH handler and just check for resize before every read.
The SIGWINCH handler triggers breakage in libedit which is hard to fix; see
PR bin/169773.

Also, window size changes while a program is in foreground (and it rather
than sh will receive SIGWINCH) will now be picked up automatically.

Downside: it is now certain that a resize is only processed after pressing
<Enter>. If libedit is fixed, sh will most likely have to be changed also.

PR:		bin/180146
2014-01-14 22:56:25 +00:00
Julio Merino
9622238c09 Replace hand-crafted Kyuafiles with automatic generation.
Redo r260506 by using the new TEST_METADATA functionality of bsd.test.mk
to mark the sh(1) and test(1) tests as not supporting root.  This is to
get rid of hand-crafted Kyuafiles for these very simple cases.

MFC after:	5 days
2014-01-14 18:45:32 +00:00
Julio Merino
d935b54263 Use TAP_TESTS_PERL to register the legacy_test in bin/pax.
Redo r260586 by using the new functionality in tap.test.mk to transparently
support perl-based test programs.

As a side-effect, we get rid of an explicit path to /usr/bin/perl by
replacing it with /usr/local/bin/perl (or as defined in tap.test.mk).

This also fixes the name of the legacy_test source file because this should
have always been legacy_test.pl and not legacy_test.sh.  My mistake when
originally moving the code around without realizing that this was a perl
script.

MFC after:	5 days
2014-01-14 18:39:30 +00:00
Julio Merino
0b7cffde5f Mark the bin/pax tests as requiring perl.
The effect of this is that the test program is marked as skipped when perl
is missing, instead of marking it as broken due to an execution failure.

MFC after:	3 days
2014-01-13 12:17:41 +00:00
Adrian Chadd
4c766481d0 Close the newly-created FD if the pathname is too long.
Coverity:	CID 1007204
Sponsored by:	Netflix, Inc.
2014-01-11 15:01:30 +00:00
Julio Merino
287083efce Run the sh(1) and test(1) tests as unprivileged.
One of the tests for test(1) fails and some of the tests for sh(1) are
silently bypassed when running as root.

To fix these tests and ensure they all run, mark the test programs for
sh(1) and test(1) as requiring an unprivileged user.  (This should and
will be the default in Kyua but isn't yet.)

MFC after:	1 week
2014-01-10 10:39:01 +00:00
Jilles Tjoelker
b14cfdf665 sh(1): Discourage use of -e.
Also, do not say that ! before a pipeline is an operator, because it is
syntactically a keyword.
2014-01-03 22:56:23 +00:00
Mark Johnston
93f7e978f6 Correct the description of the V state, which indicates that the process'
parent is suspended, not the process itself.

MFC after:	3 days
2013-12-28 03:04:05 +00:00
Jilles Tjoelker
cac001aabe sh: Don't check input for non-whitespace if history is disabled.
preadbuffer() maintained a flag whether there was any non-whitespace
character. This flag is only useful when history is enabled (in that case,
lines containing only whitespace are not added to history). Instead, check
using strspn() when history is enabled.

There is an approximate 2% speedup when running
  sh -c '. /etc/rc.subr; . /etc/defaults/rc.conf; source_rc_confs'
with hot cache.
2013-12-27 15:52:18 +00:00
Jilles Tjoelker
8191e23727 sh: Simplify code related to PPID variable. 2013-12-25 16:14:02 +00:00
Jilles Tjoelker
7e81d0c8c3 sh: Initialize OPTIND=1 even if it came from the environment. 2013-12-24 22:38:24 +00:00
Jilles Tjoelker
bd28fb4d4c sh: Remove an unused variable. 2013-12-24 22:04:44 +00:00
Chris Rees
e26f656669 Document the lack of chflags support in pax(1)
PR:		docs/135516
Submitted by:	arundel (based on)
Approved by:	gjb (mentor)
2013-12-21 19:29:08 +00:00
Julio Merino
13de33a5dc Migrate tools/regression/bin/ tests to the new layout.
This change is a proof of concept on how to easily integrate existing
tests from the tools/regression/ hierarchy into the /usr/tests/ test
suite and on how to adapt them to the new layout for src.

To achieve these goals, this change:

- Moves tests from tools/regression/bin/<tool>/ to bin/<tool>/tests/.
- Renames the previous regress.sh files to legacy_test.sh.
- Adds Makefiles to build and install the tests and all their supporting
  data files into /usr/tests/bin/.
- Plugs the legacy_test test programs into the test suite using the new
  TAP backend for Kyua (appearing in 0.8) so that the code of the test
  programs does not have to change.
- Registers the new directories in the BSD.test.dist mtree file.

Reviewed by:	freebsd-testing
Approved by:	rpaulo (mentor)
2013-12-11 04:09:17 +00:00
Jilles Tjoelker
d1670d4228 sh: Split set -x output into a separate function. 2013-12-06 22:24:37 +00:00
Jilles Tjoelker
c80ad859e1 test: Avoid looking up again the type of a known binary operator. 2013-12-05 22:53:32 +00:00
Jilles Tjoelker
577ad9b2d3 test: Simplify the code by unifying op_num and op_type.
The global variable t_wp_op is no longer needed.
2013-12-01 17:00:57 +00:00
Jilles Tjoelker
670dd3f08f sh: Prefer memcpy() to strcpy() in most cases. Remove the scopy macro. 2013-11-30 21:27:11 +00:00
Jilles Tjoelker
1b57cec7d9 sh: Make <&0 disable the </dev/null implicit in a background command.
Although <&0 does nothing, it is a redirection affecting standard input and
should therefore disable the </dev/null redirection implicit in a background
command.
2013-11-24 23:12:13 +00:00
Jilles Tjoelker
5d4d10e3e5 sh: Properly quote alias output from command -v.
An alias should be printed by command -v as a command line; therefore, make
the alias definition suitable for re-input to the shell.
2013-11-10 23:00:39 +00:00
Eitan Adler
03eea902e7 pkill - Optimize pgrep -F
Ask for a specific process instead of pulling down all processes when
 -F <pidfile> is specified.  This is much much faster.

 Obtained from:	DragonflyBSD
2013-11-10 05:22:29 +00:00
Jilles Tjoelker
d2c068eaac sh(1),limits(1): Document kqueues (-k) rlimit. 2013-11-01 13:57:30 +00:00
Jilles Tjoelker
fd692a70aa sh: Reorder union node to reduce its size on 64-bit platforms. 2013-11-01 11:28:56 +00:00
Jilles Tjoelker
efd1946c35 sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'.
If job control is not enabled, background jobs started with  ... &  ignore
SIGINT and SIGQUIT so that they are not affected by such signals that are
intended for the foreground job. However, this should not prevent
reassigning a different action for these signals (as if the shell invocation
inherited these signal actions from its parent).

Austin group issue #751

Example:
  { trap - INT; exec sleep 10; } & wait
A Ctrl+C should terminate the sleep command.
2013-10-30 21:36:15 +00:00
Christian Brueffer
b5a8b741f7 Clean up a spurious "." in SEE ALSO.
MFC after:	3 days
2013-10-28 23:02:12 +00:00
Konstantin Belousov
85a0ddfd0b Add a resource limit for the total number of kqueues available to the
user.  Kqueue now saves the ucred of the allocating thread, to
correctly decrement the counter on close.

Under some specific and not real-world use scenario for kqueue, it is
possible for the kqueues to consume memory proportional to the square
of the number of the filedescriptors available to the process.  Limit
allows administrator to prevent the abuse.

This is kernel-mode side of the change, with the user-mode enabling
commit following.

Reported and tested by:	pho
Discussed with:	jmg
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2013-10-21 16:46:12 +00:00
Edward Tomasz Napierala
c5985c1f9f Don't test arrays for being NULL.
MFC after:	1 month
2013-10-21 09:12:04 +00:00
Jilles Tjoelker
bab2982266 sh: Remove one syscall when waiting for a foreground job.
The getpgrp() call is unnecessary: if there is no job control then the
result was not used at all and if there is job control then we are not a
subshell and our process group ID is equal to our process ID (rootpid).
2013-10-18 12:35:12 +00:00
Simon J. Gerraty
09127a3637 New/updated dependencies 2013-10-17 19:59:51 +00:00
Simon J. Gerraty
3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
Simon J. Gerraty
34b33809b7 Updated dependencies 2013-10-13 00:24:00 +00:00
Dag-Erling Smørgrav
7014092551 Remove extraneous \n.
Noticed by:     Nikolai Lifanov <lifanov@mail.lifanov.com>

Approved by:	re (gjb)
2013-10-11 20:10:18 +00:00
Dag-Erling Smørgrav
5f3850777e By popular demand, move freebsd-version(1) from /libexec to /bin.
Approved by:	re (gjb)
2013-10-09 20:47:20 +00:00
Edward Tomasz Napierala
cc8f0608ee Remove useless check - ki_loginclass is an array; can't be NULL.
CID:		1006559
Approved by:	re (kib)
MFC after:	2 weeks
Sponsored by:	FreeBSD Foundation
2013-10-04 16:08:44 +00:00
Sergey Kandaurov
05d98029e9 Sweep man pages replacing ad -> ada.
Approved by:	re (blackend)
MFC after:	1 week
X-MFC note:	stable/9 only
2013-10-01 18:41:53 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Jilles Tjoelker
2935c4cc5e 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
2013-09-04 22:10:16 +00:00
Jilles Tjoelker
b823fb59f1 sh: Fix race condition with signals and wait or set -T.
The change in r238888 was incomplete. It was still possible for a trapped
signal to arrive before the shell went to sleep (sigsuspend()) because a
check was missing or because the signal arrived before in_waitcmd was set.

On SMP, this bug sometimes caused the builtins/wait4.0 test to take 1 second
to execute; it then might or might not fail. On UP, the test almost always
failed.
2013-09-02 21:57:46 +00:00
Jilles Tjoelker
32187151d8 sh: Simplify list() in the parser.
The erflag argument was only used by old-style (``) command substitutions.
We can remove it and handle the special case in the command substitution
code.
2013-08-30 20:50:28 +00:00
Jilles Tjoelker
510739cc24 sh: Separate out nbinary allocation into a function. 2013-08-30 20:37:52 +00:00
Jilles Tjoelker
47752ed647 sh: Use makename() where possible. 2013-08-30 20:13:33 +00:00
Jilles Tjoelker
6ab99f87b7 sh: Add a function for the case where one token is required in the parse. 2013-08-30 13:25:15 +00:00
Jilles Tjoelker
65519ccb4d sh: Recognize "--" as end of options in type builtin.
This implementation makes minimal changes: command names starting with "-"
(other than "--") can still be queried normally.
2013-08-30 12:09:59 +00:00
Jilles Tjoelker
f52924b480 sh: Cast -1 to pointer rather than pointer to variable of wrong type.
NEOF needs to be a non-null pointer distinct from valid union node pointers.
It is not dereferenced.

The new NEOF is much like SIG_ERR except that it is an object pointer
instead of a function pointer.

The variable tokpushback can now be static.
2013-08-30 10:45:02 +00:00
Will Andrews
5e9ccc8797 Add the ability to display the default FIB number for a process to the
ps(1) utility, e.g. "ps -O fib".

bin/ps/keyword.c:
	Add the "fib" keyword and default its column name to "FIB".

bin/ps/ps.1:
	Add "fib" as a supported keyword.

sys/compat/freebsd32/freebsd32.h:
sys/kern/kern_proc.c:
sys/sys/user.h:
	Add the default fib number for a process (p->p_fibnum)
	to the user land accessible process data of struct kinfo_proc.

Submitted by:	Oliver Fromme <olli@fromme.com>, gibbs
2013-08-26 23:48:21 +00:00
Jilles Tjoelker
71828da5ff sh: Recognize "--" as end of options in alias builtin.
Aliases starting with "-" (which are non-POSIX) will need to be preceded by
an alias not starting with "-" or the newly added "--".
2013-08-25 11:42:53 +00:00
Jilles Tjoelker
3cfb11c41a sh: Disallow empty simple commands.
As per POSIX, a simple command must have at least one redirection,
assignment word or command word.

These occured in rare cases such as  eval "f()" .

The extension of allowing no commands inside { }, if, while, for, etc.
remains.
2013-08-25 10:57:48 +00:00
Jilles Tjoelker
7e6e930d1e sh: Reject ++ and -- in arithmetic.
POSIX does not require ++ and -- in arithmetic. It is probably more useful
to reject them than to treat ++x and --x as x silently.

Note that the behaviour of increment and decrement can be obtained via
(x+=1), ((x+=1)-1), (x-=1) and ((x-=1)+1).

PR:		bin/176444
2013-08-24 20:06:00 +00:00
Jilles Tjoelker
7cb5a0d863 sh: Do not prematurely discard stopped jobs in a wait builtin.
If a job is specified to 'wait', wait for it to complete. Formerly, in
interactive mode, the job was deleted if it stopped.

If no jobs are specified in interactive mode, 'wait' still waits for all jobs
to complete or stop.

In non-interactive mode, WUNTRACED is not passed to wait3() so stopped jobs
are not detected.

PR:		bin/181435
2013-08-24 09:57:32 +00:00
Kenneth D. Merry
7da1a731c6 Expand the use of stat(2) flags to allow storing some Windows/DOS
and CIFS file attributes as BSD stat(2) flags.

This work is intended to be compatible with ZFS, the Solaris CIFS
server's interaction with ZFS, somewhat compatible with MacOS X,
and of course compatible with Windows.

The Windows attributes that are implemented were chosen based on
the attributes that ZFS already supports.

The summary of the flags is as follows:

UF_SYSTEM:	Command line name: "system" or "usystem"
		ZFS name: XAT_SYSTEM, ZFS_SYSTEM
		Windows: FILE_ATTRIBUTE_SYSTEM

		This flag means that the file is used by the
		operating system.  FreeBSD does not enforce any
		special handling when this flag is set.

UF_SPARSE:	Command line name: "sparse" or "usparse"
		ZFS name: XAT_SPARSE, ZFS_SPARSE
		Windows: FILE_ATTRIBUTE_SPARSE_FILE

		This flag means that the file is sparse.  Although
		ZFS may modify this in some situations, there is
		not generally any special handling for this flag.

UF_OFFLINE:	Command line name: "offline" or "uoffline"
		ZFS name: XAT_OFFLINE, ZFS_OFFLINE
		Windows: FILE_ATTRIBUTE_OFFLINE

		This flag means that the file has been moved to
		offline storage.  FreeBSD does not have any special
		handling for this flag.

UF_REPARSE:	Command line name: "reparse" or "ureparse"
		ZFS name: XAT_REPARSE, ZFS_REPARSE
		Windows: FILE_ATTRIBUTE_REPARSE_POINT

		This flag means that the file is a Windows reparse
		point.  ZFS has special handling code for reparse
		points, but we don't currently have the other
		supporting infrastructure for them.

UF_HIDDEN:	Command line name: "hidden" or "uhidden"
		ZFS name: XAT_HIDDEN, ZFS_HIDDEN
		Windows: FILE_ATTRIBUTE_HIDDEN

		This flag means that the file may be excluded from
		a directory listing if the application honors it.
		FreeBSD has no special handling for this flag.

		The name and bit definition for UF_HIDDEN are
		identical to the definition in MacOS X.

UF_READONLY:	Command line name: "urdonly", "rdonly", "readonly"
		ZFS name: XAT_READONLY, ZFS_READONLY
		Windows: FILE_ATTRIBUTE_READONLY

		This flag means that the file may not written or
		appended, but its attributes may be changed.

		ZFS currently enforces this flag, but Illumos
		developers have discussed disabling enforcement.

		The behavior of this flag is different than MacOS X.
		MacOS X uses UF_IMMUTABLE to represent the DOS
		readonly permission, but that flag has a stronger
		meaning than the semantics of DOS readonly permissions.

UF_ARCHIVE:	Command line name: "uarch", "uarchive"
		ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE
		Windows name: FILE_ATTRIBUTE_ARCHIVE

		The UF_ARCHIVED flag means that the file has changed and
		needs to be archived.  The meaning is same as
		the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and
		the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute.

		msdosfs and ZFS have special handling for this flag.
		i.e. they will set it when the file changes.

sys/param.h:		Bump __FreeBSD_version to 1000047 for the
			addition of new stat(2) flags.

chflags.1:		Document the new command line flag names
			(e.g. "system", "hidden") available to the
			user.

ls.1:			Reference chflags(1) for a list of file flags
			and their meanings.

strtofflags.c:		Implement the mapping between the new
			command line flag names and new stat(2)
			flags.

chflags.2:		Document all of the new stat(2) flags, and
			explain the intended behavior in a little
			more detail.  Explain how they map to
			Windows file attributes.

			Different filesystems behave differently
			with respect to flags, so warn the
			application developer to take care when
			using them.

zfs_vnops.c:		Add support for getting and setting the
			UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN,
			UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags.

			All of these flags are implemented using
			attributes that ZFS already supports, so
			the on-disk format has not changed.

			ZFS currently doesn't allow setting the
			UF_REPARSE flag, and we don't really have
			the other infrastructure to support reparse
			points.

msdosfs_denode.c,
msdosfs_vnops.c:	Add support for getting and setting
			UF_HIDDEN, UF_SYSTEM and UF_READONLY
			in MSDOSFS.

			It supported SF_ARCHIVED, but this has been
			changed to be UF_ARCHIVE, which has the same
			semantics as the DOS archive attribute instead
			of inverse semantics like SF_ARCHIVED.

			After discussion with Bruce Evans, change
			several things in the msdosfs behavior:

			Use UF_READONLY to indicate whether a file
			is writeable instead of file permissions, but
			don't actually enforce it.

			Refuse to change attributes on the root
			directory, because it is special in FAT
			filesystems, but allow most other attribute
			changes on directories.

			Don't set the archive attribute on a directory
			when its modification time is updated.
			Windows and DOS don't set the archive attribute
			in that scenario, so we are now bug-for-bug
			compatible.

smbfs_node.c,
smbfs_vnops.c:		Add support for UF_HIDDEN, UF_SYSTEM,
			UF_READONLY and UF_ARCHIVE in SMBFS.

			This is similar to changes that Apple has
			made in their version of SMBFS (as of
			smb-583.8, posted on opensource.apple.com),
			but not quite the same.

			We map SMB_FA_READONLY to UF_READONLY,
			because UF_READONLY is intended to match
			the semantics of the DOS readonly flag.
			The MacOS X code maps both UF_IMMUTABLE
			and SF_IMMUTABLE to SMB_FA_READONLY, but
			the immutable flags have stronger meaning
			than the DOS readonly bit.

stat.h:			Add definitions for UF_SYSTEM, UF_SPARSE,
			UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY
			and UF_HIDDEN.

			The definition of UF_HIDDEN is the same as
			the MacOS X definition.

			Add commented-out definitions of
			UF_COMPRESSED and UF_TRACKED.  They are
			defined in MacOS X (as of 10.8.2), but we
			do not implement them (yet).

ufs_vnops.c:		Add support for getting and setting
			UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY,
			UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS.
			Alphabetize the flags that are supported.

			These new flags are only stored, UFS does
			not take any action if the flag is set.

Sponsored by:	Spectra Logic
Reviewed by:	bde (earlier version)
2013-08-21 23:04:48 +00:00
Jilles Tjoelker
9bb8ccd642 sh: Remove unnecessary reset functions.
These are already handled by exception handlers.
2013-08-16 20:24:41 +00:00
Jilles Tjoelker
f0ef49bbf4 sh: Recognize "--" as end of options in bg/fg/jobid builtins. 2013-08-16 13:56:43 +00:00
Jilles Tjoelker
056fd329b9 sh: Recognize "--" as end of options in local builtin. 2013-08-14 21:59:48 +00:00
Jilles Tjoelker
adc2e8dfb4 sh: Allow a lone redirection before '|', ';;' or ';&'.
Example: </dev/null | :

PR:		181240
MFC after:	1 week
2013-08-14 19:34:13 +00:00
Edward Tomasz Napierala
cc55ad3d72 Add -c flag to pgrep(1) and pkill(1), to match login classes.
MFC after:	1 month
2013-08-09 08:38:51 +00:00
Jilles Tjoelker
b6dda50adc sh: Remove an incorrect comment. 2013-07-25 20:50:35 +00:00
Jilles Tjoelker
0bdd387178 sh: Remove #define MKINIT.
MKINIT only served for the removed mkinit. Many variables can be static now.
2013-07-25 19:48:15 +00:00
Jilles Tjoelker
338b821b0f sh: Remove mkinit.
Replace the RESET blocks with regular functions and a reset() function that
calls them all.

This code generation tool is unusual and does not appear to provide much
benefit. I do not think isolating the knowledge about which modules need to
be reset is worth an almost 500-line build tool and wider scope for
variables used by the reset functions.

Also, relying on reset functions is often wrong: the cleanup should be done
in exception handlers so that no stale state remains after 'command eval'
and the like.
2013-07-25 15:08:41 +00:00
Jilles Tjoelker
f85336594c 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).
2013-07-25 13:09:17 +00:00
Jilles Tjoelker
fd7d6d8a29 sh: Do not read from stdin if an error occurs during -i -c cmd.
Although using -i with -c does not seem very useful, it seems inappropriate
to read commands from the terminal in this case.

Side effect: if the -s -c extension is used and the -s option is turned off
using 'set +s' during the interactive part, the shell now exits after an
error or interrupt. Note that POSIX only specifies -s as option to sh, not
to set.

See also Austin Group issue #718.
2013-07-12 15:29:41 +00:00
Tim Kientzle
9d40e340ea Fix a -Wunsequenced warning.
Submitted by:	dt71@gmx.com
2013-06-29 15:49:26 +00:00
Jilles Tjoelker
42580a3efa sh: Do not close(-1) if pipe() fails. 2013-06-28 21:47:08 +00:00
Jilles Tjoelker
0c35cec686 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.
2013-06-14 22:06:18 +00:00
Jilles Tjoelker
c6ef00e390 sleep: Explain in a comment why the [EINTR] check is there.
Suggested by:	eadler
2013-06-05 20:15:18 +00:00
Jilles Tjoelker
bd76c6b83f sh(1): Document new features in wait builtin.
PR:		176916
2013-06-05 19:54:28 +00:00
Jilles Tjoelker
79b1d31887 sh: Return status 127 for unknown jobs in wait builtin.
This is required by POSIX, at least for pids that are not known child
processes.

Other problems with job specifications still cause wait to abort with
exit status 2.

PR:		176916
2013-06-05 19:40:52 +00:00
Jilles Tjoelker
a4099656c3 sh: Allow multiple operands in wait builtin.
This is only part of the PR; the behaviour for unknown/invalid pids/jobs
remains unchanged (aborts the builtin with status 2).

PR:		176916
Submitted by:	Vadim Goncharov
2013-06-05 19:08:22 +00:00
Eitan Adler
08aa7c869f Add 'static' where able. 2013-06-02 17:55:00 +00:00
Jilles Tjoelker
a5efad6f0d test(1): Add information about replacing -nt/-ot. 2013-05-31 22:57:04 +00:00
Jilles Tjoelker
28bb6b493a test(1): List non-standard primaries. 2013-05-31 22:55:21 +00:00
Jilles Tjoelker
f19825af72 test: Remove -ntXY and -otXY primaries.
This reverts commit r247274.

As maintainer of sh, I disapprove of this feature addition.

It is too specific and can be done without easily using find(1) or stat(1).
I will add some hints to the test(1) man page shortly.

In general, FreeBSD sh is not the place to invent new shell language
features. This is how it has been maintained and adding features randomly
does not work with that.

The new syntax (e.g. [ FILE1 -ntca FILE2 ]) looks cryptic to me.
2013-05-31 22:54:20 +00:00
Jilles Tjoelker
c2cfcb6063 sleep: Improve nanosleep() error handling:
* Work around kernel bugs that cause a spurious [EINTR] return if a
   debugger (such as truss(1)) is attached.

 * Write an error message if an error other than [EINTR] occurs.

PR:		bin/178664
2013-05-28 22:07:31 +00:00
Greg Lehey
c9e571fe9d Complete revision 243104. 2013-05-17 03:52:20 +00:00
Xin LI
41f05c8281 Constify parameters, no functional or binary change.
Verified with:	sha256(1)
MFC after:	2 weeks
2013-05-15 18:38:28 +00:00
Joel Dahl
2710751bc3 mdoc sweep. 2013-05-12 22:22:12 +00:00
Jilles Tjoelker
336e0c87fa sh: Remove linked list of stack marks.
The linked list of stack marks may cause problems if the allocation stack is
used between an exception and a higher-level popstackmark(), as it may then
touch a stack mark that is local to a function which has returned.

Also, the adjustment compares to a pointer passed to realloc(), which is
undefined behaviour.

Instead of adjusting stack marks when reallocating stack blocks, ensure that
such an adjustment is never necessary by fixing a small piece of memory in
place at a stack mark. This also simplifies the code.

To avoid the problems reported in bin/175922, it remains necessary to call
setstackmark() after popstackmark() if the stack mark remains in use.
2013-05-11 20:51:00 +00:00
Eitan Adler
4ac1163902 Make dd's signal handler async safe.
PR:		bin/75258
Submitted by:	"Oleg V. Nauman" <oleg@reis.zp.ua>
Arrival Date:	Sun Dec 19 14:50:21 GMT 2004
Reviewed by:	mjg, jhb
Reviewed by:	jilles (earlier version)
MFC after:	1 week
2013-05-10 18:43:36 +00:00
Eitan Adler
6c7d832824 Fix two typos
Reviewed by:	jilles
2013-05-09 21:29:16 +00:00
Jilles Tjoelker
5aa6dfda1c sh: Use O_CLOEXEC and F_DUPFD_CLOEXEC instead of separate fcntl() call. 2013-05-05 10:51:40 +00:00
Jilles Tjoelker
c4539460e3 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.
2013-05-03 15:28:31 +00:00
Eitan Adler
fbf59d5891 Mark usage() __dead2 2013-04-28 22:52:43 +00:00
Eitan Adler
cdbf4feea9 Remove cast that was only required for K&R C.
Reviewed by:	jilles
2013-04-28 22:05:01 +00:00
Eitan Adler
bfefd42150 Add missing static qualifiers
Reviewed by:	ed, jilles
MFC After:	3 days
2013-04-27 21:59:43 +00:00
Jilles Tjoelker
58c73bab93 sh: Don't consider jobs -s/-p as reporting the status of jobs.
This ensures that something like j=$(jobs -p) does not prevent any
status from being written to the terminal.
2013-04-27 14:07:25 +00:00
Eitan Adler
4c99904b9a Add two more 'static' qualifiers 2013-04-26 17:56:35 +00:00
Eitan Adler
9d6d3f96d0 Take some improvements from DragonFlyBSD:
- add const where appropriate
	- add static where appropriate
	- fix a whitespace issues

Reviewed by:	brooks
Obtained from:	DragonFlyBSD
MFC After:	1 week
2013-04-26 17:45:40 +00:00
Eitan Adler
d4319e7433 Add -x option to avoid crossing mount points when removing a hierarchy.
Discussed on:	-hackers
Inspired by:	DragonflyBSD
MFC After:	1 week
2013-04-26 17:45:37 +00:00
Ulrich Spörlein
e83643f4f6 Don't appease clang static analyzer after all and roll back
the free(3) of mntbuf ... again. There's no point in doing
useless extra work when we're about to exit.

See also r240565.

Not reading file history:	uqs
2013-04-26 12:27:30 +00:00
Konstantin Belousov
6784d416a5 Literally follow POSIX:
If the bs= expr operand is specified and no conversions other than sync,
noerror, or notrunc are requested, the data returned from each input
block shall be written as a separate output block.

In particular, when both bs=size and conv=sparce were specified, the
resulted file was fully filled, instead of sparce.

PR:	standards/177742
Submitted by:	Matthew Rezny <mrezny@hexaneinc.com>
MFC after:	2 weeks
2013-04-23 16:08:24 +00:00
Eitan Adler
e99f8bc02e - Add the __dead2 attribute since it is a function that never returns
- Add an empty line in usage() according to style(9)

PR:		bin/177076
Submitted by:	Fernando <fernando.apesteguia@gmail.com>
Approved by:	cperciva (mentor)
2013-04-23 13:03:11 +00:00
Joel Dahl
224359b52c Point users towards nisdomainname and rc.conf.
PR:		144630
Submitted by:	Stefan Krueger <stadtkind2@gmx.de>,
		Fel <wtfcrap@mail.ru>
2013-04-22 17:55:12 +00:00
Joel Dahl
1ca3beb91f Document a few expansions for the $PS1 and $PS2 environmental variables.
PR:		173410
Submitted by:	Derek Wood <ddwood@outlook.com>
Reviewed by:	jilles
2013-04-21 19:55:38 +00:00
Ulrich Spörlein
11ed25f278 bin/df: Fix unitialized use in prtstat
While here:
- use NULL in the context of pointers
- use memset instead of bzero throughout the file
- free memory to appease clang static analyzer

Found by:	Coverity Scan (the UNINIT one)
2013-04-20 12:41:05 +00:00
Kenneth D. Merry
21b6ee96fc Update chio(1) and ch(4) to support reporting element designators.
This allows mapping a tape drive in a changer (as reported by
'chio status') to a sa(4) driver instance by comparing the
serial numbers.

The designators can be ASCII (which is printed out directly), binary
(which is printed in hex format) or UTF-8, which is printed in either
native UTF-8 format if the terminal can support it, or in %XX notation
for non-ASCII characters.  Thanks to Hiroki Sato <hrs@> for the
explaining UTF-8 printing and example UTF-8 printing code.

chio.h:		Modify the changer_element_status structure to add new
		fields and definitions from the SMC3r16 spec.

		Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
		define a new CHIOGSTATUS ioctl.

		Clean up some tab/space issues.

chio.c: 	For the 'status' subcommand, print the designator field
		if it is supplied by a device.

scsi_ch.h:	Add new flags for DVCID and CURDATA to the READ
		ELEMENT STATUS command structure.

		Add a read_element_status_device_id structure
		for the data fields in the new standard. Add new
		unions, dt_or_obsolete and voltage_devid, to hold
		and address data from either SCSI-2 or newer devices.

scsi_ch.c:	Implement support for fetching device IDs with READ
		ELEMENT STATUS data.

		Add new arguments to scsi_read_element_status() to
		allow the user to request the DVCID and CURDATA bits.
		This isn't compiled into libcam (it's only an internal
		kernel interface), so we don't need any special
		handling for the API change.

		If the user issues the new CHIOGSTATUS ioctl, copy all of
		the available element status data out.  If he issues the
		OCHIOGSTATUS ioctl, we don't copy the new fields in the
		structure.

		Fix a bug in chopen() that would result in the peripheral
		never getting unheld if chgetparams() failed.

Sponsored by:	Spectra Logic
Submitted by:	Po-Li Soong
MFC After:	1 week
2013-04-19 20:03:51 +00:00
Ed Schouten
7e659f9491 Add the Clang specific -Wmissing-variable-declarations to WARNS=6.
This compiler flag enforces that that people either mark variables
static or use an external declarations for the variable, similar to how
-Wmissing-prototypes works for functions.

Due to the fact that Yacc/Lex generate code that cannot trivially be
changed to not warn because of this (lots of yy* variables), add a
NO_WMISSING_VARIABLE_DECLARATIONS that can be used to turn off this
specific compiler warning.

Announced on:	toolchain@
2013-04-19 19:45:00 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Jilles Tjoelker
6e0f89a4b4 sh: Don't modify exit status when break/continue/return passes !.
This matches what would happen if  ! P  were to be replaced with
if P; then false; else true; fi.

Example:
  f() { ! return 0; }; f
2013-04-12 15:19:35 +00:00
Jilles Tjoelker
7d919c164d sh: Add const to nodesavestr(). 2013-04-07 16:28:36 +00:00
Brooks Davis
c183a03b17 IFP4 change 222074.
Introduce an explicit close of the output descriptor so that work done
on close is accounted for in the summary output triggered at exit
(implicit close()s occur after atexit() hooks).

This is useful because some devices such as cfi(4) may perform
signficant work after a close occurs (e.g. erasing and rewriting a
block of flash).
2013-04-03 19:19:45 +00:00
Jilles Tjoelker
c6a453a430 sh: Write as much into the heredoc pipe as possible, to avoid forking.
Use non-blocking I/O to write as much as the pipe will accept (often 64K,
but it can be as little as 4K), avoiding the need for the ugly PIPESIZE
constant. If PIPESIZE was set too high, a deadlock would occur.
2013-04-02 21:34:38 +00:00
Jilles Tjoelker
46c6b52dfb sh: Fix various compiler warnings.
It now passes WARNS=7 with clang on i386.

GCC 4.2.1 does not understand setjmp() properly so will always trigger
-Wuninitialized. I will not add the volatile keywords to suppress this.
2013-04-01 17:18:22 +00:00
Edward Tomasz Napierala
f8992fccda Mention that read_attributes, write_attributes, read_acl and write_acl
are always permitted for the file owner.

PR:		kern/174948
MFC after:	1 week
2013-04-01 13:17:28 +00:00
Joel Dahl
5127efa399 Minor mdoc fix. 2013-03-29 08:12:09 +00:00
Jilles Tjoelker
54ccc8b588 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.
2013-03-24 22:48:45 +00:00
John-Mark Gurney
699d72c5fc Fix compiling ed w/ WITHOUT_ED_CRYPTO... These variables aren't
used..

Submitted by:   deeptech71 at gmail dot com
2013-03-23 19:04:57 +00:00
Pawel Jakub Dawidek
b4b2596b97 - Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of type
u_long. Before this change it was of type int for syscalls, but prototypes
  in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not
  for lchflags(2)) stated that it was u_long. Now some related functions
  use u_long type for flags (strtofflags(3), fflagstostr(3)).
- Make path argument of type 'const char *' for consistency.

Discussed on:	arch
Sponsored by:	The FreeBSD Foundation
2013-03-21 22:44:33 +00:00
Jilles Tjoelker
d70ad6f2d0 sh: Recognize "--" and explicitly reject options in wait builtin.
If syntactically invalid job identifiers are to be taken as jobs that exited
with status 127, this should not apply to options, so that we can add
options later if need be.
2013-03-15 20:29:31 +00:00
Joel Dahl
e9e3a1ab1f Add a few examples.
Obtained from:	OpenBSD
2013-03-15 20:12:54 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00