Commit Graph

3423 Commits

Author SHA1 Message Date
Ed Maste
4be62405c0 cat: fix build with -DNO_UDOM_SUPPORT
Sponsored by:	The FreeBSD Foundation
2017-08-09 18:23:46 +00:00
Kyle Evans
d0bc27e435 df(1): Add --si as an alias for -H
Reviewed by:	cem (earlier version), emaste
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D11749
2017-08-09 01:24:52 +00:00
Lawrence Stewart
27181846bb pgrep naively appends the delimiter to all PIDs including the last
e.g. "pgrep -d, getty" outputs "1399,1386,1309,1308,1307,1306,1305,1302,"
Ensure the list is correctly delimited by suppressing the emission of the
delimiter after the final PID.

Reviewed by:	imp, kib
MFC after:	1 week
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D8537
2017-08-08 00:31:10 +00:00
Enji Cooper
3783c851d7 Don't check result of chflags in f_flag_cleanup()
This will prevent false positives from occurring if the test is run on
ZFS since ZFS doesn't support fflags throbbing like UFS.

PR:	221189
MFC after:	4 days
MFC with:	r321949
2017-08-05 16:58:02 +00:00
Enji Cooper
3e46b70f38 Always use first parameter passed to get_filesystem(..) instead of discarding it
and using `.` instead.

MFC after:	1 week
MFC with:	r321949
PR:	221189 [1], 221188 [2]
2017-08-02 21:20:49 +00:00
Enji Cooper
2d3e9c25f1 Add expected failures for ZFS
- :f_flag fails on ZFS because UF_IMMUTABLE isn't supported [1].
- :v_flag fails on ZFS because the mode for foo is [always] updated
  unnecessarily.

get_filesystem(..) (supporting function that was added to the test script)
is based on equivalent logic in usr.bin/extattr/tests/extattr_test.sh .

MFC after:	1 week
PR:	221189 [1], 221188 [2]
2017-08-02 21:18:54 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Edward Tomasz Napierala
4162d13907 Use the "tree" word in ps(1) -d option description, to make it easier
to find.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-07-22 10:38:44 +00:00
Ed Maste
819129649d date: avoid crash on invalid time
localtime(3) returns NULL when passed an invalid time_t but date(1)
previously did not handle it. Exit with an error in that case.

PR:		220828
Reported by:	Vinícius Zavam
Reviewed by:	cem, kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11660
2017-07-20 15:28:48 +00:00
Jilles Tjoelker
93c3eab50c sh: Remove broken #ifdef NOHACK code (related to sh -c).
Apart from the fact that subtle syntactic changes make a poor compile-time
option, the NOHACK case has been obviously broken since it was added,
because it uses q uninitialized if (*p != '\0').

No functional change is intended.
2017-07-18 19:00:15 +00:00
Enji Cooper
8aea3ca0a7 Remove unnecessary make logic added in r319339
This makes the change cleaner and easier to backport to ^/stable/10.

MFC after:	now
2017-07-18 17:29:12 +00:00
Enji Cooper
01df7d10a5 Remove SUBDIR ordering/uniquifying in *bin/Makefile
After the addition of SUBDIR.yes, uniquifying/ordering the SUBDIRs doesn't
make a whole lot of sense, and it's in effect a half measure.

Ordering SUBDIR (after adding SUBDIR.yes to it) in bsd.subdir.mk is a
separate change that warrants more discussion/testing, because while
the SUBDIR_PARALLEL work largely fixed dependency ordering for SUBDIRs,
there might be downstream FreeBSD consumers that rely on the SUBDIR
ordering.

MFC after:	2 months
Reviewed by:	bdrewery
Differential Revision:	D11398
2017-07-06 04:15:30 +00:00
Allan Jude
1f3f7ac7ba Add deprecation notices for all rcmd tools
Submitted by:	bcr
Reviewed by:	emaste, bapt, jhl
MFC after:	immediate
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D11471
2017-07-04 15:44:30 +00:00
Pedro F. Giffuni
be9e8bfaea ed(1): Allow the omission of one address in (.,.) and (.;.) address ranges
With this patch, ",n" is an abbreviation for "1,n", ";n" abbreviates
".;n". The "n," and "n;" variants mean "n,n" and "n;n", respectively.
Also, piping to a shell command does not count as a save, so don't reset
the modified flag.

Obtained from:	OpenBSD (CVS Rev. 1.58, 1.59)
2017-07-03 15:54:44 +00:00
Jilles Tjoelker
6f49cd266b sh: Ignore error when cd writes the directory actually switched to.
If CDPATH is used non-trivially or the operand is "-", cd writes the
directory actually switched to. (We currently do this only in interactive
shells, but POSIX requires this in non-interactive shells as well.)

As mentioned in Austin group bug #1045, cd shall not return an error while
leaving the current directory changed. Therefore, ignore any write error.
2017-06-25 21:53:08 +00:00
Alan Somers
f01753c151 style fixes in bin/echo/tests
Submitted by:	shivansh
Reviewed by:	asomers
MFC after:	2 weeks
X-MFC-With:	319626
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11318
2017-06-23 15:02:49 +00:00
Enji Cooper
00bc472686 Don't expect :sF_flag to fail anymore
While here, also add a check to verify that the link target
is updated in the testcase

MFC after:	1 month
MFC with:	r320172
PR:		219943
Differential Revision:	D11167
Submitted by:	shivansh
Sponsored by:	Google (GSoC 2017)
2017-06-20 20:50:54 +00:00
Enji Cooper
63bd650f4b ln(1): fix -F behavior
When '-F' option is used, the target directory needs to be unlinked.
Currently, the modified target ("target/source") is being unlinked, and
since it doesn't yet exist, the original target isn't removed.
This is fixed by skipping the block where target is modified to
"target/source" when '-F' option is set.
Hence, a symbolic link (with the same name as of the original target) to
the source_file is produced.

Update the test for ln(1) to reflect fix for option '-F'

MFC after:	1 month
PR:		219943
Differential Revision:	D11167
Submitted by:	shivansh
Sponsored by:	Google (GSoC 2017)
2017-06-20 20:46:08 +00:00
Phil Shafer
dfde8e4b54 Use {T:Capacity} for header so html output looks tidy
Submitted by:	phil
Approved by:	sjg
2017-06-13 05:38:40 +00:00
Enji Cooper
0773ff183a Style fixes: clean up leading whitespace (8 single column spaces -> \t)
MFC after:	1 month
MFC with:	r319714, r319854, r319855, r319856
2017-06-12 16:53:42 +00:00
Enji Cooper
b01fe519c3 ln(1): wordsmith -F option description
MFC after:	1 month
2017-06-12 16:43:29 +00:00
Enji Cooper
ed66391a6e Add a testcase for ln -sF
The testcase fails today, so mark it with atf_expect_fail: in
particular, the target (B) isn't being unlinked and the documentation
doesn't suggest special handling for directories. Thus, there's either
a doc or an implementation bug in ln(1) that needs to be resolved.

MFC after:	1 month
MFC with:	r319714, r319854, r319855
PR:		219943
Reviewed by:	ngie
Submitted by:	shivansh
Differential Revision:	D11159 (part of a larger diff)
Sponsored by:	Google, Inc (GSoC 2017)
2017-06-12 16:38:37 +00:00
Enji Cooper
07b984360c Use readlink(1)/stat(1) to query symlinks instead of file(1)
file(1) can be compiled out of the system via MK_FILE == no, and the
output isn't guaranteed to be stable. It's better to use stat(1)/readlink(1)
instead to query symlink/file paths.

MFC after:	1 month
MFC with:	r319714, r319854
Reported by:	ngie
Submitted by:	shivansh
Differential Revision:	D11159 (part of a larger diff)
Sponsored by:	Google, Inc (GSoC 2017)
2017-06-12 16:31:32 +00:00
Alan Somers
e61b0afc1c bin/ln: Set umask appropriately before creating files for testing
These changes were missed in D11084

Submitted by:	shivansh
Reviewed by:	asomers
MFC after:	1 month
X-MFC-With:	319714
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11158
2017-06-12 14:54:59 +00:00
Jilles Tjoelker
55c2cd6f48 sh: Enable interrupts before executing EXIT trap and doing final flush. 2017-06-11 16:54:04 +00:00
Alan Somers
670f178299 Add tests for ln(1)
* Verify that when creating a hard link to a symbolic link, '-L' option
  creates a hard link to the target of the symbolic link
* Verify that when creating a hard link to a symbolic link, '-P' option
  creates a hard link to the symbolic link itself
* Verify that if the target file already exists, '-f' option unlinks it so
  that link may occur
* Verify that if the target file or directory is a symbolic link, '-shf'
  option prevents following the link
* Verify that if the target file or directory is a symbolic link, '-snf'
  option prevents following the link
* Verify that '-s' option creates a symbolic link
* Verify that '-w' option produces a warning if the source of a symbolic
  link does not currently exist

Submitted by:	shivansh
Reviewed by:	asomers, ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D11084
2017-06-08 19:09:55 +00:00
Enji Cooper
245e210cc6 Add some basic tests for chmod(1)
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-07 05:33:56 +00:00
Enji Cooper
7c91b65f54 Add testcases for cat -b
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-06 21:50:00 +00:00
Jilles Tjoelker
79fb1e455e sh: Call fc -e editor with interrupts enabled.
Starting the fc -e editor can execute arbitrary script, and executing
arbitrary script with INTOFF in effect may cause unexpected results.

This change (together with other changes) serves mainly to allow asserting
that INTOFF is not in effect when starting the evaluation of a node.
2017-06-06 21:08:05 +00:00
Enji Cooper
9086e0e068 Add additional testcases for cat(1)
Verify the following additional cases:
- -s (in isolation, in addition to the -se testcase obtained via the
      NetBSD test).
- -vt

Submitted by:	shivansh
Reviewed by:	asomers (earlier diff), ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	D11020
2017-06-06 21:03:43 +00:00
Enji Cooper
2d15c3cb12 Add basic tests for echo(1)
Verify that echo(1) does not...
- ... print the trailing newline character with option '-n'.
- ... print the trailing newline character when '\c' is appended to
      the end of the string.

Submitted by:	shivansh
Reviewed by:	asomers, ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	D11036
2017-06-06 16:04:27 +00:00
Bryan Drewery
231ad771d9 Clarify -q is only for pgrep.
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-06-05 16:00:10 +00:00
Jilles Tjoelker
8d4cde8e6d sh: Make sure to process SIGINT if SETINTON re-enables processing.
If INTON re-enables interrupts, it processes any interrupt that occurred
while interrupts were disabled. Make SETINTON do the same.
2017-06-04 21:58:02 +00:00
Bryan Drewery
3ecb77f014 Allow defining nofork builtins from builtins.def and move always-safe ones there.
The generated code remains the same.

Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D11042
2017-06-04 21:02:48 +00:00
Jilles Tjoelker
eab4998278 sh: Fix INTOFF leak when a redirection on a compound command fails.
Reported by:	bdrewery
2017-06-04 20:52:55 +00:00
Alan Somers
07c19c27d3 Fix bin/dd/dd2_tests:seek_overflow on UFS and TMPFS
Split the postive and negative parts into separate test cases.  The positive
test case can only run on ZFS, because only ZFS supports files that large.

PR:		219757
Reported by:	ngie
MFC after:	18 days
X-MFC-with:	319339
2017-06-03 18:29:18 +00:00
Enji Cooper
141173eb9f Mark :seek_overflow as an expected failure
MFC after:	18 days
MFC with:	r319339
PR:		219757
Sponsored by:	Dell EMC Isilon
2017-06-03 17:59:10 +00:00
Enji Cooper
5f0aff893e Stylistic tweaks
Move opening braces of functions from the last column to column 0.

MFC after:	18 days
MFC with:	r319339
Sponsored by:	Dell EMC Isilon
2017-06-03 17:56:31 +00:00
Alan Somers
af2b6af393 Fix integer overflow detection in dd
dd(1) tried to detect whether the seek offset would overflow, but it failed
to account for the case where the provided argument was negative and the
file was a regular file (negative seeks are allowed for character devices).
I fixed it, and added a regression test.

Reported by:	Coverity
CID:		1368659
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-05-31 16:07:32 +00:00
Jilles Tjoelker
29717eb029 sh: Keep output buffer across builtins.
Allocating and deallocating repeatedly the 1024-byte buffer for stdout from
builtins costs CPU time for little or no benefit.

A simple loop containing builtins that write to a file descriptor, such as
  i=0; while [ "$i" -lt 1000000 ]; do printf .; i=$((i+1)); done >/dev/null
is over 10% faster in a simple benchmark on an amd64 virtual machine.
2017-05-18 22:10:04 +00:00
Jilles Tjoelker
de29cd0869 sh: Ensure memout.bufsize matches allocated buffer, if it exists. 2017-05-18 21:44:14 +00:00
Jilles Tjoelker
5183ddf2ed sh: Simplify output buffering.
Similarly to how STPUTC was changed, change struct output to store the
pointer just past the end of the available space instead of the size of the
available space, so after writing a character it is only necessary to
increment a pointer and not to decrement a counter.
2017-05-16 21:54:51 +00:00
Jilles Tjoelker
1b21b7fa89 sh: Fix '-' from quoted arithmetic in case/glob pattern range.
It does not make much sense to generate the '-' in a pattern bracket
expression using arithmetic expansion, but it does not make sense to forbid
it either.

Try to avoid reprocessing the string if it is unnecessary.
2017-05-14 13:14:19 +00:00
Jilles Tjoelker
73a73f7bd2 sh: Add test for arithmetic expansion in [x-y] pattern range.
It does not make much sense to generate the '-' in a pattern bracket
expression using arithmetic expansion, but it does not make sense to forbid
it either.

This test already passes.
2017-05-13 20:28:32 +00:00
Bryan Drewery
07676084ec DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-05-09 01:48:23 +00:00
Jilles Tjoelker
3f2da875f7 sh: Fix INTOFF leak after a builtin with different locale settings.
After executing a builtin with different locale settings such as
  LC_ALL=C true
SIGINT handling was left disabled indefinitely.

MFC after:	1 week
2017-05-07 19:49:46 +00:00
Edward Tomasz Napierala
452bdaabb5 .Xr resizewin from stty(1) man page.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-05-07 11:44:25 +00:00
Jilles Tjoelker
b98072777f sh: Update TOUR and comments for some code changes, some of them old.
Also, improve some terminology in TOUR and comments.
2017-05-06 13:28:42 +00:00
Jilles Tjoelker
d4993b6db2 sh: Simplify handling of newlines in command substitution.
Unless we need to split on newlines, just append them as normal and remove
them at the end.
2017-04-28 16:16:22 +00:00
Jilles Tjoelker
24b55fb76d sh: Add some tests for command substitution final newline stripping. 2017-04-27 18:52:18 +00:00