Commit Graph

3768 Commits

Author SHA1 Message Date
Kyle Evans
9fcac31db4 date: attempt to more accurately describe year limitations with -v
The previous description was both incorrect and incomplete in its
description -- the 2038 limit doesn't apply on !i386 platforms, and
it didn't note that values above 100 are accepted and interpreted
differently.  Further, it didn't note that absolute years are accepted.

Reviewed by:	pauamma_gundo.com (manpages)
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D35360
2022-06-27 22:54:13 -05:00
Mateusz Piotrowski
d46d907a26 sleep.1: Fix mdoc style
Fixes:	be038c3afc bin/sleep: add support for multiple delay values
MFC after:	1 week
2022-05-25 10:11:33 +02:00
Warner Losh
f5dcfbe36e stty: Remove stray '-'.
There's a stray '-' that causes Fl to double the dash, but that's not
how the command works.

MFC After:		2 days
Sponsored by:		Netflix
2022-05-24 14:31:28 -06:00
Stefan Eßer
81cea61f3b bin/sleep: document more non-standard features
Add support of other time units than seconds to the IMPLEMENTATION
NOTES section of the man page.

MFC after:	1 week
2022-05-24 11:31:21 +02:00
Stefan Eßer
be038c3afc bin/sleep: add support for multiple delay values
The sleep time is calculated as the sum of all arguments passed.

This makes the FreeBSD version of sleep functionally compatible with
the version in GNU coreutils.

MFC after:	1 week
2022-05-24 10:47:40 +02:00
A. Mallory
34978f7edd bin/sleep: add support for units other than seconds
The coreutils version of this command accepts a unit designation of s,
m, h, or d (for seconds, minutes, hours, days) immediately following
the number of (fractional) units to delay.

The submitted patch has been modified in one detail: the test meant to
detect the presence of the unit modified was not specific (!= 1) and
would have accepted a non-numeric initial element or extra characters
following the union. The committed version accepts only the number
immediately followed by one of the defined unit designators and no
further characters.

PR:		264162
MFC after:	1 week
2022-05-24 09:43:38 +02:00
Gordon Bergling
ffedb32dd3 pax(1): Remove a few double words in source code comments
- s/an an/an/

MFC after:	3 days
2022-04-09 14:27:39 +02:00
Kyle Evans
f00f8b4fbd cp: fix -R recursion detection
The correct logic is a lot simpler than the previous iteration.  We
record the base fts_name to avoid having to worry about whether we
needed the root symlink name or not (as applicable), then we can simply
shift all of that logic to after path translation to make it less
fragile.

If we're copying to DNE, then we'll have swapped out the NULL root_stat
pointer and then attempted to recurse on it.  The previously nonexistent
directory shouldn't exist at all in the new structure, so just back out
from that tree entirely and move on.

The tests have been amended to indicate our expectations better with
subdirectory recursion.  If we copy A to A/B, then we expect to copy
everything from A/B/* into A/B/A/B, with exception to the A that we
create in A/B.

Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34655
2022-04-05 20:41:00 -05:00
Greg Lehey
8deef88628 Correct source markup. No change to output.
Reported by:	0mp@
2022-03-30 14:55:28 +11:00
Greg Lehey
8e4b069f45 Remove reference to kernel clock time zone.
Add references.

Reported by:	philip@
2022-03-30 14:42:14 +11:00
Piotr Pawel Stefaniak
68700941c7 sh: fix autocompletion for commands that share name with a directory
Provide libedit a special function making it always add a space after
the autocompleted command. The default one adds a slash if the word is
also a name of a directory in the current working directory, but this is
wrong for commands.

Reviewed by:	bapt, jilles
Differential Revision: https://reviews.freebsd.org/D34544
2022-03-28 08:45:03 +02:00
Greg Lehey
3c9f304b38 Describe modern time zone handling.
Reviewed by:	peterj@
MFC after:	2 weeks
2022-03-28 14:57:37 +11:00
Alfonso
3322d1c0e2 ps(1): Use calloc instead of malloc and memset.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/546
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-11 10:36:00 +01:00
Baptiste Daroussin
2eee44bd5e df: do not report a 100% full inode usage on fs without inodes
Before:
devfs    2        2         0   100%       0          0  100%   /dev

After:
devfs    2        2         0   100%       0          0     -   /dev

The previous behaviour was confusing for end users and many monitoring tools

Note the linux df tools is also using the same syntax '-' for such filesystem

MFC After:		2 weeks
Reviewed by:		manu, emaste, imp
Differential Revision:	https://reviews.freebsd.org/D34515
2022-03-11 08:49:44 +01:00
Cameron Katri
97e1303791 cp: Make -P work without -R as per POSIX
According to POSIX, cp should allow the `-P` flag to work whether `-R`
is specified or not.  Currently, the `-P` option only works along with
`-R`.

PR:		199466
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D30012
2022-02-23 12:55:13 -06:00
Kyle Evans
33ad990ce9 cp: fix -R with links
The traversal was previously not properly honoring -H/-L/-P.  Notably,
we should not have been resolving symlinks encountered during traversal
when either -H or -P are specified.

Sponsored by:	Klara, Inc.
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D34063
2022-02-22 16:06:02 -06:00
Stefan Eßer
f0fd4a32c4 bin/df: allow -t option to be used together with -l
The df command provides a -l option to exclude all non-local file
systems and a -t option with a (positive or negative) list of file
system types to display.

This commit adds support for a combination of -l and -t. If both are
specified, the parameter list of the -t option is applied on top of
the selection of öocal file systems (independently of the order of
the -l and -t options).

E.g., "df -t noprocfs,sysfs -l" will select all local file systems
except those of type procfs and sysfs.

PR:		260921
Approved by:	imp
Relnotes:	yes
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D33748
2022-02-10 21:09:34 +01:00
Kyle Evans
848263aad1 cp: fix some cases with infinite recursion
As noted in the PR, cp -R has some surprising behavior.  Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar.  When you `cp -R foo foo` (where foo clearly exists), cp(1)
goes a little off the rails as it creates foo/foo, then discovers that
and creates foo/foo/foo, so on and so forth, until it eventually fails.

POSIX doesn't seem to disallow this behavior, but it isn't very useful.
GNU cp(1) will detect the recursion and squash it, but emit a message in
the process that it has done so.

This change seemingly follows the GNU behavior, but it currently doesn't
warn about the situation -- the author feels that the final product is
about what one might expect from doing this and thus, doesn't need a
warning.  The author doesn't feel strongly about this.

PR:		235438
Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D33944
2022-01-27 12:02:17 -06:00
Jilles Tjoelker
5a1a07f2a0 sh: Don't add something to a null pointer
Pointer arithmetic on a null pointer is undefined behavior.

The bug can be reproduced by running bin/sh/tests/builtins/wait6.0 with
UBSAN.

Reported by:	Mark Millard
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34011
2022-01-26 23:13:20 +01:00
Emmanuel Vadot
4991269369 pkgbase: Create a FreeBSD-csh package
Now that root uses /bin/sh as the default shell no need to have csh part
of runtime.
Put it in its own package.

MFC after:	never
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33471
2021-12-21 10:17:50 +01:00
Emmanuel Vadot
5abb10faa1 pkgbase: Put yellow pages programs to its own package
YP is less and less used, split them to users have the choice to not
install them.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33441
2021-12-21 10:17:22 +01:00
Bryan Drewery
971677d5fd sh: Avoid some headers when NO_HISTORY is set.
This is more simpler compatibility with using this source on older
systems before libedit was made to install filecomplete.h in
commit b315a7296d.
2021-11-24 17:53:39 -08:00
Hans Petter Selasky
4c537df51a echo(1): Replace errexit() with err(3)
Differential revision:	https://reviews.freebsd.org/D32501
Submitted by:	christos@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-11-09 22:12:19 +01:00
Mateusz Piotrowski
c537bf9d59 date: Capitalize seconds string in synopses
This makes it consistent with other date(1) implementations. Also, it
feels more consistent since hours and minutes are already represented as
HH and MM respectively.

MFC after:	3 days
2021-11-03 14:09:36 +01:00
Mateusz Piotrowski
a12b16f48f date: Clean up synopses
MFC after:	3 days
2021-11-03 14:09:36 +01:00
Mateusz Piotrowski
00133d5c5e date.1: Fix some style issues and examples
- Use Cm instead of Ar or Sq for command modifiers of the -v flag.
- Remove unnecessary "Ar ..." from the synopsis. It's not clear what it
  was referring to.
- Add missing arguments to the -f and -v flags.
- Stylize the dot before "ss" with Cm in the default format in the -f
  flag description.
- Set LC_ALL=C in the last example so that the output format of
  date(1) always matches the specified format of the -f flag not matter
  the locale.
- List the -f flag as optional in all usage lines in the synopsis.

MFC after:	3 days
2021-11-03 14:09:18 +01:00
Jilles Tjoelker
72f750dc7c sh: Fix heredoc at certain places in case and for
After an unescaped newline, there may be a here-document. Some places in
case and for did not check for one.

Reviewed by:	bdrewery
Differential Revision:	https://reviews.freebsd.org/D32628
2021-10-27 21:05:19 +02:00
Ka Ho Ng
fcfa64801a sh: Set PATH envvar after setting HOME in dotfile
In single-user mode, all env vars are absent, so exptilde() would not be
able to expand ~ correctly.
Place the lines setting PATH below HOME, so exptilde() would work as
expected.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	jilles, emaste
Differential Revision:	https://reviews.freebsd.org/D27003
2021-10-26 22:50:09 +08:00
Baptiste Daroussin
f3aad18d5e sh(1): fix home/del key on mobaxterm env
For $reason mobaxterm default on sending unusual sequence from home/del
key, which makes libedit unabel to catch them and bind them correctly.

mobaxterm seems popular on the windows environment, so add proper
keybinding to default shrc configuration so it works out of box.

Reported by:	lme
2021-10-20 14:00:20 +02:00
Baptiste Daroussin
ef0d94a3d3 sh(1): interactive mode improvement
In the default configuration add 2 bindings which has been requested by
many during the HEADSUP discussion:
* csh like arrow history navigation
* ctrl-arrow to jump from word to words

Add an alias to make the history command exist as an alias to fc -l.
2021-10-20 09:33:04 +02:00
Elyes HAOUAS
3fe686f25a src/bin/ps: Fix spelling error
Spell interruptible correctly.

Pull Request: https://github.com/freebsd/freebsd-src/pull/544
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:39:37 -06:00
Elyes HAOUAS
8db446034e src/bin/pax: Fix spelling error
"whats" -> "what's"

Pull Request: https://github.com/freebsd/freebsd-src/pull/544
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:39:34 -06:00
Elyes HAOUAS
28c3c137f6 src/bin/mkdir: Spell occur correctly.
Pull Request: https://github.com/freebsd/freebsd-src/pull/544
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:39:31 -06:00
Elyes HAOUAS
48556dff3d src/bin/sh: Fix spelling errors
Pull Request: https://github.com/freebsd/freebsd-src/pull/544
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:39:24 -06:00
Faraz Vahedi
f54b18fc4d freebsd-version(1): Add -j flag to support jails
Make freebsd-version(1) support jails by adding the -j flag which takes
a jail jid or name as an argument. As with other options, -j
flags stack and display in the order requested.

Reviewed by:	bcr (manpages), kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25705
2021-10-01 13:50:56 -05:00
Kyle Evans
33c1e7271a hostname: avoid strcpy() overlap in -d flag handling
We don't need the strcpy() anyways, just use a pointer to the hostname
buffer and move it forward for `hostname -d`.

Sponsored by:	Klara, Inc.
2021-09-25 00:03:50 -05:00
Math Ieu
bf27a2253f ps: fix ps -aa
Passing the -a flag multiple times made ps show no processes.

Differential Revision:	https://reviews.freebsd.org/D27215
2021-09-24 21:19:52 +02:00
Bryan Drewery
e31fb97148 read builtin: Empty variables on timeout
This matches how a non-timeout error is handled.

Reviewed by:	jilles
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D31876
2021-09-24 11:34:54 -07:00
Stephane Rochoy
d2c233176f sh: Add -o verify to use O_VERIFY when sourcing scripts
Add -o verify to sh to make it use O_VERIFY when
sourcing scripts and reading profiles.

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

Differential revision:	https://reviews.freebsd.org/D30464
Reviewed by:		jilles, sjg
Obtained from:		Stormshield
2021-09-23 10:43:09 +02:00
Piotr Pawel Stefaniak
1f82fb3834 sh: try to avoid overwriting HISTFILE produced by other shells
If an attempt to load history from an existing history file was
unsuccessful, do not try to save command history to that file on exit.
2021-09-22 22:23:32 +02:00
Piotr Pawel Stefaniak
c866d0c798 sh: improve command completion
When there are many matches, find the longest common substring starting
from the beginning of each command and use that to replace input.

As an example: on my system, llv<tab> will be autocompleted to llvm-
and another <tab> will print all matching llvm commands.
2021-09-22 22:23:32 +02:00
Piotr Pawel Stefaniak
9413dfd331 sh: reset sh bindings on bind -e, bind -v
Until this change, any bindings set in histedit() were lost on calls to
bindcmd().

Only bind -e and bind -v call libedit's keymacro_reset(). Currently you
cannot fool libedit/map.c:map_bind() by trying something like bind -le
as when p[0] == '-', it does a switch statement on p[1].
2021-09-22 10:54:51 +02:00
Baptiste Daroussin
908b8e32f9 sh: remove emacs improvements that are now defaults in libedit 2021-09-22 10:27:10 +02:00
Cameron Katri
97c31821eb ls(1): Allow LSCOLORS to specify an underline
Allows capitalizing the background color character to enable an
underline instead of bold, capitalizing the foreground color char will
still do bold.

Differential Revision:	https://reviews.freebsd.org/D30547
2021-09-19 13:52:12 +02:00
Piotr Pawel Stefaniak
b8ff849cbd sh: improve command completion
When multiple matches are found, we keep the provided string on the
input line and print unique matches as suggestions.

But the multiple matches might be the same command found in different
directories, so we should deduplicate the matches first and then decide
whether to autocomplete the command or not, based on the number of
unique matches.
2021-09-19 13:51:45 +02:00
Baptiste Daroussin
3ae61b972b sh: improve emacs mode
in emacs mode ^W should delete the previous word by default
Note that upstreaming this change directly into libedit is in process.

Reported by:	manu
Reviewed by:	jills, pstef, manu
Differential Revision:	https://reviews.freebsd.org/D29493
2021-08-28 16:11:57 +02:00
Gleb Popov
fcef0684f1 Fix build of bin/getfacl after libc changes.
Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255
2021-08-27 11:52:18 +03:00
Piotr Pawel Stefaniak
ced2dcadcc ls: prevent no-color build from complaining when COLORTERM is non-empty
As 257886 reports, if ls(1) is built with WITHOUT_LS_COLORS="YES", it
issues a warning whenever COLORTERM is non-empty. The warning is not
useful, so I thought to remove it, but as Ed pointed out, we may want
to have a way to determine whether a particular copy of ls has been
compiled with color support or not.

Therefore move the warnx() call to the getopt loop in
a WITHOUT_LS_COLORS build to fire when the user asks for colored output.

PR:		257886
Reported by:	Marko Turk
Reviewed by:	kevans
2021-08-19 21:22:16 +02:00
Piotr Pawel Stefaniak
35b253d9d2 sh: fix NO_HISTORY build
Move code added in b315a7296d ("autocomplete commands") to
conditionally compiled part under #ifndef NO_HISTORY.

Reported by:	bdrewery
Fixes:		b315a7296d
2021-08-19 06:57:06 +02:00
Mateusz Guzik
570b31f610 df: remove the unused fstype var
Found with cc --analyze

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-20 19:00:50 +02:00
Alex Richardson
2423585b1d bin/ps: Avoid function name conflict with libc uname()
This prevents ps from being built with address sanitizer instrumentation.

Reviewed By:	trasz
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31048
2021-07-19 15:04:09 +01:00
Kyle Evans
db0f264393 kenv: allow listing of static kernel environments
The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D30835
2021-07-18 23:06:19 -05:00
Kyle Evans
46438b5366 kenv: s/dump/list/ to clarify meaning
The contents of the kenv will be dumped to stdout, while dump could have
also meant 'discard'. Call it 'list' instead.

Suggested by:	imp
Reviewed by:	imp, jhb
Differential Revision:	https://reviews.freebsd.org/D30836
2021-07-18 23:05:30 -05:00
Emmanuel Vadot
2c733106ae pkgbase: Put chio in utilities
No need to bloat runtime with this utility.

Differential Revision:	https://reviews.freebsd.org/D30753
Sponsored by:	Diablotin Systems
2021-06-19 17:49:44 +02:00
Ceri Davies
3e4946f0aa date.1: Remove mention of -d and -f flags
These flags were removed in 2019.

PR:		256631
Submitted by:	David Fiander <david@fiander.info>
MFC After:	3 days
2021-06-16 09:18:56 +00:00
Baptiste Daroussin
988b1bb0c5 sh: implement persistent history storage
Implement persistent history storage:
the strategy is simple at start: loads the existing .sh_history file
at exit dump it.

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

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

Co-authored-by:	pstef
Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D29493
2021-05-10 18:57:13 +02:00
Piotr Pawel Stefaniak
1a4e959eb3 sh: fix debug build
Approved by:	jilles
2021-04-11 09:23:14 +02:00
Gordon Bergling
3ce579325e ed(1): Add two references in the SEE ALSO section
Obtained from:	OpenBSD
MFC after:	1 week
2021-04-09 09:43:49 +02:00
Piotr Pawel Stefaniak
5a18515b31 sh: silence sanitizer
Don't add 0 to a null pointer.
Reviewed by:	jilles
2021-04-01 07:31:03 +02:00
Baptiste Daroussin
660045fb53 sh: improve emacs mode
In emacs mode, force ^R to backware search the history
This behaviour is the default in emacs mode for most of the other shells

Note: Note that this can still be overridden via $EDITRC, ~/.editrc or a
bind command after set -o emacs.

MFC after:		1 week
Approved by:		jilles
Reviewed by:		jilles, arichardson, pstef
Differential Revision:	https://reviews.freebsd.org/D29494
2021-03-30 23:49:03 +02:00
Piotr Pawel Stefaniak
b315a7296d sh(1): autocomplete commands
Without this patch, sh can autocomplete file names but not commands from
$PATH. Use libedit's facility to execute custom function for autocomplete,
but yield to the library's standard autocomplete function when cursor is
not at position 0.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29361
2021-03-29 11:14:27 +02:00
Alex Richardson
5ff2e55e00 bin/pkill: Fix {pgrep,pkill}-j_test.sh
The POSIX sh case statement does not allow for pattern matching using the
regex + qualifier so this case statement never matches. Instead just check
for a string starting with a digit followed by any character.

While touching these files also fix various shellcheck warnings.

`kyua -v parallelism=4 test` failed before, succeeds now.

Reviewed By:	imp
Differential Revision: https://reviews.freebsd.org/D28480
2021-02-13 13:53:51 +00:00
Baptiste Daroussin
45b252fc91 cp: fix indentation
No functional changes
2021-01-27 12:18:45 +01:00
Alexander V. Chernikov
bbff3a72b2 Fix typo in pwait.c introduced in 5bdce6ff54
Reported by:	kevans
2021-01-21 21:43:27 +00:00
Alexander V. Chernikov
5bdce6ff54 Remove deadlock in rc caused by pwait waiting for itself.
The following situation can trigger the deadlock:
1) Long time ago a_service was started through rc.d
2) We want to restart a_service and issue service a_service restart
3) rc.subr reads current process PID (via file or process),
   sends TERM signal and runs pwait with PID harvested
4) a_service process dies very quickly so it's PID becomes available.
   It is possible that while original process was running,
   PID counter overflowed and pwait got assigned a_service's PID.

This patch ignores pid(s) to wait that are equal to pwait PID.

Reported by:	Dan McGregor, Boris Lytochkin
Submitted by:	Boris Lytochkin <lytboris at gmail.com>
Reviewed By:	0mp
MFC after:	2 weeks
PR:		218598
Differential Revision: https://reviews.freebsd.org/D28240
2021-01-21 21:36:37 +00:00
Mariusz Zaborski
0614d73967 cat: style nits
Pointed out by:	jhb
2021-01-20 18:46:26 +01:00
Mateusz Piotrowski
a0e85d0eb5 Remove the unnecessary space before the colon
MFC after:	3 days
2021-01-20 09:46:15 +01:00
Ed Maste
e83b514a95 cat: depend on Makefile to rebuild when WITH_CASPER changes
We try to ensure building WITHOUT_CLEAN (or -DNO_CLEAN) works on an
ongoing basis.  b7ab6832cd changed cat to build w/o -DWITH_CASPER
by default; add a cat.o dependency on the Makefile so that it gets
rebuilt.
2021-01-17 12:19:00 -05:00
Mariusz Zaborski
b7ab6832cd cat: disable building it with Casper
We want to measure what are the actual cost of sandboxing cat(1).

Requested by:	mjg, cy, Mike Karels
Discussed with:	rwatson, markj
2021-01-17 01:21:46 +01:00
Mariusz Zaborski
de57c3d882 cat: style nits 2021-01-16 12:58:23 +01:00
Mariusz Zaborski
6e8062c855 cat: persistent errno
There is no guarantee that after close(2)/free the errno will remain
persistent. The caller of the udom_open function depends on the errno
for reporting errors.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D28185
2021-01-16 12:55:42 +01:00
Mariusz Zaborski
c664d8dfc3 cat: Fix potential memory leak
This was introduced in aefe30c543.
2021-01-15 21:49:52 +01:00
Mariusz Zaborski
aefe30c543 cat: capsicumize it
Reviewed by:	markj, arichardson
Differential Revision:	https://reviews.freebsd.org/D28083
2021-01-15 21:23:42 +01:00
Alex Richardson
ed8455806e Fix all warnings emitted in make kernel-toolchain
With this change and D27598 make kernel-toolchain no longer emits any
warnings for me.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D27599
2021-01-07 09:26:22 +00:00
Jilles Tjoelker
52981a1694 sh/tests: Add a second kind of binary scripts without #!
One of the reasons for git commit
e0f5c1387d was to make "actually portable
executables" work. Add a test that is more like those.

MFC after:	1 week
2021-01-03 23:53:37 +01:00
Rick Macklem
c98a764c68 cp(1): fix performance issue for large non-sparse file copies
PR252358 reported a serious performance problem when
copying a large non-sparse file on a UFS file system.
This problem seems to have been caused by a large
number of SEEK_HOLE operations, with one done
for each copy_file_range(2) call.

This patch modifies cp(1) to use a large (SSIZE_MAX)
len argument, reducing the number of system calls
and resolving the performance issue.

While here, convert the type of the "rcount" from "int"
to "ssize_t" so that it is consistent with that returned
by both read(2) and copy_file_range(2).

PR:	252358
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D27937
2021-01-02 16:58:43 -08:00
Benjamin Kaduk
43d0803c45 Soften caveat about fractional seconds for sleep(1)
Support for fractional seconds has become much more widespread since
this text was originally written.

Reported by:    Mark Eichin
Reviewed by:    gbe, jilles
Differential Revision:  https://reviews.freebsd.org/D26208
2020-12-31 19:18:20 -08:00
Stefan Eßer
50fcb4ee77 Replace sscanf() by strtoul()
This change has been motivated by a mail from bde sent in 2015 in
which he mentioned inappropriate use of sscanf() in 3 programs in
/bin.

This change removes the potential mismatch of the types of the return
values and the variable width specified in the scan pattern. While
there was no issue with the patterns and types used, the new code is
simpler and more efficient.
2020-12-27 22:32:22 +01:00
Stefan Eßer
3fee777ec5 Simplify LS_COLWIDTHS processing
The previous version normalized the width list (replaced empty fields
with "0") just to be able to use sscanf() on the string.

It is much simpler to just parse the string as-is.

The clearing of f_notabs is preserved for the case that less than 9
width values have been defined, but I do not understand the rationale
for this particular condition. E.g., LS_COLWIDTHS="::::::::" will be
counted as 9 defined fields (may clear f_notabs) but is no different
fron LS_COLWIDTHS="" with regard to the field width (and that does not
clear f_notabs, since there are less than 9 fields).
2020-12-27 22:32:22 +01:00
Jilles Tjoelker
ab41d7f371 sh: Explain duplicate tcsetpgrp() calls
This is a comment change only.
2020-12-26 15:27:33 +01:00
Xin LI
1cc908de3a Remove unused includes. 2020-12-22 21:04:36 -08:00
Xin LI
dd1ce6c7f1 Remove unused headers.
MFC after:	2 weeks
2020-12-12 02:26:43 +00:00
Xin LI
3601af4da2 Remove unneeded headers.
MFC after:	2 weeks
2020-12-12 02:24:33 +00:00
Bryan Drewery
2dfa4b66b3 fts_read: Handle error from a NULL return better.
This is addressing cases such as fts_read(3) encountering an [EIO]
from fchdir(2) when FTS_NOCHDIR is not set.  That would otherwise be
seen as a successful traversal in some of these cases while silently
discarding expected work.

As noted in r264201, fts_read() does not set errno to 0 on a successful
EOF so it needs to be set before calling it.  Otherwise we might see
a random error from one of the iterations.

gzip is ignoring most errors and could be improved separately.

Reviewed by:	vangyzen
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D27184
2020-12-08 23:38:26 +00:00
Gleb Popov
caeb270e9f bin/setfacl: Little refactoring, no functional change.
The acl_from_stat function accepts a stat_t * argument, but only uses its
st_mode field. There is no reason to pass the whole struct, so make it accept
a mode_t and rename the function to acl_from_mode.
Linux has non-standard acl_from_mode function in its libacl, so naming the
function this way may help discovering it during porting efforts.

Reviewed by:	tsoome, markj
Approved by:	markj
Differential Revision:	https://reviews.freebsd.org/D27292
2020-11-23 17:00:06 +00:00
Mark Johnston
1740c2dbb6 df: Remove support for mounting devices
This was marked deprecated in r329092, over two and a half years ago.
This functionality is also buggy per PR 237368.

PR:		237368
Reviewed by:	brooks, cem, emaste, imp
Differential Revision:	https://reviews.freebsd.org/D27197
2020-11-13 16:47:42 +00:00
Li-Wen Hsu
a249b285b7 Whitespace cleanup
MFC after:	3 days
2020-10-29 14:44:09 +00:00
Li-Wen Hsu
62dc3e7c6d Remove superfluous this in comment
PR:		250721
Submitted by:	Hiroya EBINE <hebiyan@protonmail.com>
MFC after:	3 days
2020-10-29 14:42:02 +00:00
Fernando Apesteguía
64e352c6df pwd(1): Add EXAMPLES section
Small EXAMPLES section.

Add reference to realpath(1) due to similarity.

Approved by:	manpages (gbe@)
Differential Revision:		https://reviews.freebsd.org/D26862
2020-10-24 16:42:35 +00:00
Fernando Apesteguía
76ec6f51b9 realpath(1): Add EXAMPLES section.
Add a small example for this simple command.

Approved by:	manpages (gbe@)
Differential Revision:		https://reviews.freebsd.org/D26863
2020-10-20 13:15:26 +00:00
Gordon Bergling
05c207e9e0 ls(1): Use \& as an escape character for the ',' option
Reported by:	karels@, xtouqh at hotmail dot com
MFC after:	1 day
2020-10-10 13:39:13 +00:00
Fernando Apesteguía
3d17b350e5 pkill(1): Add EXAMPLES section to man page
Add a dozen of examples to the EXAMPLES section for pgrep(1) and pkill(1).

Flags covered: -f, -F, -n, -j, -l, -S, -x

Approved by:	mandoc (bcr@)
Differential Revision:	pkill(1): Add EXAMPLES section to man page
2020-10-05 13:52:31 +00:00
Fernando Apesteguía
a8f6fe34fd kenv(1): Add EXAMPLES to man page
Add EXAMPLES section covering all the options

Approved by:	manpages (bcr@)
Differential Revision:	https://reviews.freebsd.org/D26664
2020-10-05 13:49:45 +00:00
Fernando Apesteguía
5145778475 hostname(1): Add EXAMPLES to man page
Add a very simple set of examples

Approved by:	manpages (bcr@)
Differential Revision:	https://reviews.freebsd.org/D26663
2020-10-05 13:46:19 +00:00
Fernando Apesteguía
ad3d2e7e4a df(1): Add EXAMPLES section to man page
* Add EXAMPLES section with four simple examples.
* Simplify -H flag description. This makes easy to see the difference between
  this flag and -h
* While here, fix .Tn deprecated macro.

Approved by:	manpages (bcr@)
Differential Revision:	https://reviews.freebsd.org/D26662
2020-10-05 13:39:37 +00:00
Fernando Apesteguía
270a486931 pwait(1): Add EXAMPLES section to man page
* Add small EXAMPLES section to the man page showing the different
  flags and exit codes.

* Complete description for -v flag.

Approved by:	manpages (bcr@)
2020-10-05 13:35:34 +00:00
Gordon Bergling
5388e0e3e8 cp(1): Bugfixes for some issues reported by mandoc
- no blank before trailing delimiter

MFC after:	1 week
2020-10-03 18:36:22 +00:00
Gordon Bergling
0853ef565e ls(1): Bugfix for an issue reported by mandoc
- no blank before trailing delimiter

MFC after:	1 week
2020-10-03 18:34:24 +00:00
Kyle Evans
5779bba93e cp: tests: fix weird 20 insertion
This slipped in at the last moment. =(
2020-09-23 03:02:45 +00:00
Kyle Evans
5028ea32d6 cp: add some basic tests
There are some tests available in the NetBSD test suite, but we don't
currently pass all of those; further investigation will go into that. For
now, just add a basic test as well as a test that copies from /dev/null to a
file.

The /dev/null test confirms that the file gets created if it's empty, then
that it truncates the file if it's non-empty. This matches some usage that
was previously employed in the build and was replaced in r366042 by a
simpler shell construct.

I will also plan on coming back to expand these in due time.

MFC after:	1 week
2020-09-23 03:01:14 +00:00