Commit Graph

3225 Commits

Author SHA1 Message Date
Bryan Drewery
d1dd034d07 META_MODE: Don't rebuild build-tools targets during normal build.
This avoids 'build command changed' due to CFLAGS/CC changes during the
normal build.  Without this the build-tools targets end up rebuilding
for the *target* rather than keeping the native versions built in
build-tools.

Sponsored by:	EMC / Isilon Storage Division
2016-04-14 21:06:10 +00:00
Jilles Tjoelker
d72505899b sh: Simplify code by removing variable bracketed_name. 2016-04-13 20:32:35 +00:00
Pedro F. Giffuni
3b7175bdc7 rcp(1): replace 0 with NULL for pointers.
Found with devel/coccinelle.
2016-04-11 17:24:26 +00:00
Pedro F. Giffuni
74136dc300 sh(1): replace 0 with NULL for pointers.
Found with devel/coccinelle.

Reviewed by:	jilles
2016-04-09 20:05:39 +00:00
Jilles Tjoelker
4a9f41ec82 sh: Fix some unquoted variables in tests.
The builtins/getopts1.0 test failed if a single-character file existed in
the current directory.
2016-04-09 16:06:13 +00:00
Mark Peek
c8a8eb16e0 Revert r296416 by removing SAVESIGVEC and switching to fork instead. This
fixes usage with system libraries which maintain their own signal state.

PR:             208132
Obtained from:  kib
MFC after:	3 days
2016-04-07 14:25:15 +00:00
Jilles Tjoelker
f30e8c7e71 sh: Fix use-after-free if a trap replaces itself.
MFC after:	1 week
2016-03-28 18:58:40 +00:00
Edward Tomasz Napierala
225636dccb Fix bunch of .Xrs.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-28 16:48:28 +00:00
Bryan Drewery
46a0387a46 CCACHE_BUILD: Don't use ccache when generating some files with CC -E.
At least for ncurses this fixes a build error due to it trying to run
'ccache --version' to work around a gcc 5 bug using the fix in r287205.

Sponsored by:	EMC / Isilon Storage Division
2016-03-24 21:48:13 +00:00
Jilles Tjoelker
7d980385e8 sh: Fix copying uninitialized field 'special'.
This just copied uninitialized data and did not depend on it later, so it
should not be dangerous.

Found by:	clang static analyzer
2016-03-13 22:54:14 +00:00
Konstantin Belousov
250d9fd8aa Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add
login.conf(5) support.

Reviewed by:	jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D5610
2016-03-12 14:54:34 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Jilles Tjoelker
6dbe471130 sh: Add test for 'set -o nolog'.
The option does not do anything so check that the output of 'set +o' is
different.
2016-03-09 21:05:21 +00:00
Jilles Tjoelker
c94a041f43 sh: Avoid out-of-bounds access in setoptionbyindex() for 'set -o nolog'.
Reported by:	hrs
2016-03-09 21:00:57 +00:00
Jilles Tjoelker
acb4eada18 sh: Fix some dead stores.
Found by:	clang static analyzer
2016-03-06 17:24:02 +00:00
Mark Peek
26526cb970 Signal handling within tcsh vfork code path will conflict with some system
libraries (such as libthr) which maintain their own signal state. This
change adds the tcsh SAVESIGVEC option to save and restore the sigvecs for
the signals the child modifies before it execs.

Reviewed by:	kib, rwatson
Reported by:	kib
2016-03-05 19:55:42 +00:00
Jilles Tjoelker
2efd8c0a6c sh: Remove a redundant STPUTC check. 2016-03-02 22:52:54 +00:00
Jilles Tjoelker
90a2c7ea86 sh: Don't trust that signal descriptions fit within 49 bytes. 2016-03-02 21:24:46 +00:00
Edward Tomasz Napierala
3ea98e058d dump(1) -> dump(8).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-29 17:17:10 +00:00
Konstantin Belousov
1bdbd70599 Implement process-shared locks support for libthr.so.3, without
breaking the ABI.  Special value is stored in the lock pointer to
indicate shared lock, and offline page in the shared memory is
allocated to store the actual lock.

Reviewed by:	vangyzen (previous version)
Discussed with:	deischen, emaste, jhb, rwatson,
	Martin Simmons <martin@lispworks.com>
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-02-28 17:52:33 +00:00
Edward Tomasz Napierala
75e5511214 Add speed limit to dd(1). This is useful for testing RCTL disk io limits
(when they actually get committed, that is), and might also come in handy
in other situations.

Reviewed by:	wblock@ (man page)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-28 10:27:12 +00:00
Bryan Drewery
bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by:	EMC / Isilon Storage Division
2016-02-24 17:20:11 +00:00
Jilles Tjoelker
84f1891033 sh: Fix set -v and multiline history after r295825.
r295825 erroneously dropped the newline from the input data for 'set -v'
output and multiline history.

Reported by:	vangyzen
2016-02-23 22:44:01 +00:00
Jilles Tjoelker
2ece338651 sh: Don't hash alias name when there are no aliases. 2016-02-21 20:58:24 +00:00
Jilles Tjoelker
c39f3bac71 sh: Optimize setprompt(0).
Avoid doing work to print an empty prompt (such as when reading scripts).
2016-02-21 18:54:17 +00:00
Jilles Tjoelker
3b3c9ccf08 sh: Remove unnecessary flushouts while reading script.
Output is flushed when a builtin is done or immediately after writing it
(error messages, set -v output, prompts).
2016-02-21 16:48:37 +00:00
Edward Tomasz Napierala
674677bd08 Make the "invalid numeric value" error message actually displayable
(was a dead code before).

Submitted by:	bde@ (earlier version)
Reviewed by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-21 14:36:50 +00:00
Jilles Tjoelker
dcd95d8a01 sh: Rework code to remove '\0' from shell input.
This fixes bugs where '\0' was not removed correctly and speeds up the
parser.
2016-02-19 21:53:12 +00:00
Jilles Tjoelker
a3ec59c20a sh: Add tests for comments in sh -c. 2016-02-19 16:56:07 +00:00
Thomas Quinot
cd1832fe92 Reorganize the handling all-zeroes terminal block in sparse mode
The intent of the previous code in that case was to force
an explicit write, but the implementation was incorrect, and
as a result the write was never performed. This new implementation
instead uses ftruncate(2) to extend the file with a trailing hole.

Also introduce regression tests for these cases.

PR: 189284
(original PR whose fix introduced this bug)

PR: 207092

Differential Revision:	D5248
Reviewed by:	sobomax,kib
MFC after:	2 weeks
2016-02-18 08:44:16 +00:00
Bryan Drewery
d3157f0915 Test directories can build in parallel fine.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:13:59 +00:00
Konstantin Belousov
db57c70a5b Rename P_KTHREAD struct proc p_flag to P_KPROC.
I left as is an apparent bug in ntoskrnl_var.h:AT_PASSIVE_LEVEL()
definition.

Suggested by:	jhb
Sponsored by:	The FreeBSD Foundation
2016-02-09 16:30:16 +00:00
Edward Tomasz Napierala
c075c8bb77 Improve comment to reflect recent changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:38:05 +00:00
Edward Tomasz Napierala
f30414423a Use a proper type for return value of postfix_to_mult(); the way it's
being used wouldn't work if the value returned didn't fit in intmax_t.

Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:37:04 +00:00
Edward Tomasz Napierala
d819236121 Use proper functions for parsing the numeric values.
Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:32:10 +00:00
Edward Tomasz Napierala
e53d0abf73 Add 't' and 'p' postfixes to dd(1).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:21:01 +00:00
Edward Tomasz Napierala
66d082c84b Reduce code duplication.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:10:08 +00:00
Bryan Drewery
f408f6043a Don't link /usr/share/nls/de_DE.UTF-8/tcsh.cat to itself.
Sponsored by:	EMC / Isilon Storage Division
2016-02-03 23:37:24 +00:00
Hajimu UMEMOTO
e4b59b10f8 The charset of NLS catalogs were converted to UTF-8
since r231990.
2016-02-03 11:44:43 +00:00
Hajimu UMEMOTO
46c57c6794 Make dynamic link of libiconv from ports work again.
The symbols of libiconv from ports were changed to
have prefixed.
Since we have iconv in our libc these days, we don't
need it on 10.X and later.  However, 9.X still need
this.

Spotted by:	Yoshihiko Sarumaru
MFC after:	1 days
2016-02-02 11:51:18 +00:00
Jilles Tjoelker
bd9b38d1f7 sh: Don't allocate a redirtab if there are no redirections.
Builtins (including variable assignments without command word), function
calls and redirected compound commands need to restore file descriptors
to their original state after execution. This is handled by allocating a
redirtab structure. These mallocs and frees show up heavily in pmcstat.

Only allocate a redirtab if there are actually redirections and maintain a
count of how many levels of REDIR_PUSH there are without redirtabs.

A simple loop without external programs like

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do
    i=$((i+1)); done'

is over 25% faster on an amd64 bhyve VM.
2016-01-30 21:21:25 +00:00
Jilles Tjoelker
7b6779b66b sh(1): Document 'cd -'.
This reflects the changes in r294649 and can therefore not be MFCed by
itself.
2016-01-30 20:10:20 +00:00
Jilles Tjoelker
f1602fa511 test: Optimize operator lookup.
The linear search using strcmp() shows up in pmcstat for several percent.

Split the operators into lengths and whether they start with '-' and compare
bytes using == instead of strcmp().

A simple test

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do
    v=$(printf %sx%s "$w" "$w"); i=$((i+1)); done'

is over 4% faster on an amd64 bhyve VM.
2016-01-30 19:59:58 +00:00
Jilles Tjoelker
52d5897d50 sh: Constify internal representation in expand.c.
Forbid (temporary or permanent) modifications of the strings in NARG nodes
during expansion.

Tilde expansion now needs to copy the username for the terminating '\0'.
2016-01-24 22:26:25 +00:00
Jilles Tjoelker
d5119a2a9a sh: Remove a global variable from cd.c. 2016-01-24 17:01:34 +00:00
Jilles Tjoelker
7b40c6df95 sh: Use OLDPWD shell variable for 'cd -'.
Per POSIX, 'cd -' should use the OLDPWD shell variable, not internal state.
This variable is normally exported.

Also, if OLDPWD is not set, fail 'cd -' instead of changing to the current
directory.
2016-01-23 23:00:38 +00:00
Edward Tomasz Napierala
fe819ced32 Don't mention the "canonical six" in setfacl(1); it describes semantics
that's long gone.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-01-23 12:19:37 +00:00
Jilles Tjoelker
a9bdd616f9 sh: Clean a readonly local, even if the variable does not exist outside.
If a local variable has been made read-only, this should not prevent its
removal when the function returns.
2016-01-22 20:10:08 +00:00
Jilles Tjoelker
cce13d6539 sh: Add already working test for local-readonly interaction. 2016-01-22 18:10:36 +00:00
Jilles Tjoelker
6b8e48f45e sh: Simplify some code related to positional parameters. 2016-01-19 22:41:26 +00:00