aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* cp: Correct description of SIGINFODag-Erling Smørgrav2026-07-231-2/+2
| | | | | | | | | | | The manual page claimed that SIGINFO caused information to be printed to stdout, when in fact it is printed to stderr, as one would expect. This has been true ever since the feature was first added in 2003. MFC after: 1 week Fixes: 00d321a2b395 ("Add a SIGINFO handler.") Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D58392
* cat: Fix a NULL pointer dereferenceJane Smith2026-07-211-1/+2
| | | | | | | | Check the `fdopen` return value before calling `cook_cat`. Reviewed by: markj, bnovkov Differential Revision: https://reviews.freebsd.org/D57741 MFC after: 1 week
* sh.1: Document which features are non-POSIXArtem Bunichev2026-07-201-16/+63
| | | | | | | | | Point out which features are non-POSIX and thus can not be safely assumed to be portable and exist in other implementations. Relnotes: YES! Reviewed by: ziaee, jilles Differential Revision: https://reviews.freebsd.org/D55333
* chflags.1: Document the new UF_DONTCACHE flagRick Macklem2026-07-121-1/+3
| | | | | | | | | | | Commit 74654ba3b1b3 added and new chflags(1) flag called "udontcache" or "dontcache". This patch documents this flag. This is a content change. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D58181
* ps.1: Fix broken comment lineArtem Bunichev2026-07-051-2/+2
| | | | | | | | | While here, remove the long-unused dash in the first line. Reviewed by: ziaee, olce Fixes: ddf144a04b53 ("ps.1: Revamp: Explain general principles, update to match reality") MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D58038
* ps(1): Fix a few typos in the manual pageGordon Bergling2026-06-271-4/+4
| | | | | | | | - s/occurence/occurrence/ - s/occurences/occurrences/ - s/ouput/output/ MFC after: 3 days
* kern: add a security knob to disable unprivileged access to kenvKyle Evans2026-06-221-1/+9
| | | | | | | | | | | | | | | | | We sometimes store sensitive things in the kenv that get zapped, but we really shouldn't rely on that zapping to actually happen. Most unprivileged processes don't really need to read from the kernel environment in the first place, so add a knob that allows it to be disabled. Note that we consider jailed root to be unprivileged from this perspective; they have their own meta/env concepts and we should encourage users to take advantage of those for passing information to jails. "Hey we should do something about that": dch Reviewed by: imp, ziaee, zlei (all slightly previous version) Differential Revision: https://reviews.freebsd.org/D57697
* sh: Belatedly bump manual page dateDag-Erling Smørgrav2026-06-201-1/+1
| | | | Fixes: 556e793d803e ("sh: Improve function documentation")
* rmdir.1: Document non-POSIX -v optionArtem Bunichev2026-06-191-1/+5
| | | | | | MFC after: 3 days Reviewed by: ziaee Differential Revision: https://reviews.freebsd.org/D57675
* sh: Improve function documentationDag-Erling Smørgrav2026-06-161-9/+16
| | | | | | | | | | | | | | | | | | | | * Mention that the function body can be in parentheses. It is already implied since the function body can be any valid statement, but it may not be obvious to a reader who has only ever seen functions that used curly brackets and assumes that they are part of the function syntax. * Remove the incorrect claim that a local statement may only occur at the top of a function. * Show that a value may be assigned to a variable in a local statement. * While here, replace unpaired double quotes with \(dq to avoid confusing syntax highlighters. PR: 296050 MFC after: 1 week Reviewed by: ziaee, jilles Differential Revision: https://reviews.freebsd.org/D57596
* symlink.7: Clean up markup and tag SPDXAlexander Ziaee2026-06-151-43/+49
| | | | | | Also unwind some parentheticals. MFC after: 3 days
* pwd.1: Fix a typo in the .dDGordon Bergling2026-06-151-1/+1
| | | | | | - s/Februrary/February/ MFC after: 1 week
* cp(1): fix -P documentation to reflect it works without -RKit Dallege2026-06-101-5/+8
| | | | | | | | | | | Since commit 97e13037915c, the -P flag works without -R as required by POSIX. Update the man page to state that only -H and -L are ignored without -R, while -P can be used independently. PR: 289959 Signed-off-by: Kit Dallege <xaum.io@gmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/2102
* tests: Avoid sleep when causing a write errorJilles Tjoelker2026-06-031-7/+8
| | | | | | | | | | | | | | Cause a write error using a fifo and wait, rather than needing a sleep to wait for something to terminate. This is faster and avoids a potential test failure on a heavily loaded system. Using /dev/full would be simpler, but it is not portable enough (it tends not to be available in jails, even). Starting programs with stdout not open or only open for read/execute/search may have unexpected side effects. Reviewed by: ngie, des Differential Revision: https://reviews.freebsd.org/D57213
* sh: Fix pipebuf limitDag-Erling Smørgrav2026-06-011-1/+1
| | | | | | | | | Since the factor is not 1, we need to provide a unit. MFC after: 1 week Fixes: 5d92f20c7d31 ("bin/sh: support RLIMIT_PIPEBUF") Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D57352
* Revert "sh/tests: Cut down builtins/read12.0 by 2 seconds"Jilles Tjoelker2026-05-252-10/+7
| | | | | | Dag-Erling Smørgrav does not like this, but I do not understand why. This reverts commit 1df431576f99c3cc26dd4ceb1a6eda864cc9f196.
* sh/tests: Add a test for long line in historyJilles Tjoelker2026-05-242-0/+28
|
* bin/sh: Fix history long line truncation/corruptionKristofer Peterson2026-05-244-76/+74
| | | | | | | | | | | | | | | | | | When reading from standard input with editline history enabled, increase buffer size to accomodate long lines so that history is recorded correctly. Cleanup el_gets() handling avoiding potentially dangerous retention of pointers to editline buffers across calls. Ensure struct parsefile objects are properly zero initialised when created. Remove push argument from setinputstring() and simplify logic as it was always called with a value of one and as was written was potentially dangerous if ever called with a value of zero. This commit does not fix long lines when history is enabled but editing is not (e.g. if there is no terminal). MFC after: 3 weeks Pull Request: https://github.com/freebsd/freebsd-src/pull/2028 Signed-off-by: Kristofer Peterson <kris@tranception.com>
* sh/tests: Cut down builtins/read12.0 by 2 secondsJilles Tjoelker2026-05-232-7/+10
| | | | | | | | | | | | Since the test assumes a 250 ms response time, there is no need to delay for 3 seconds. Instead, delay for the minimum possible 1 second. Also, fix some assertions in builtins/read11.0 and builtins/read12.0. If `set -e` is in effect, `foo` in `foo && bar` is considered tested and therefore a failure does not cause the shell to exit. Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D55191
* limits: Further RLIMIT_VMM cleanupDag-Erling Smørgrav2026-05-171-1/+4
| | | | | | | | Teach limits(1), sh(1), and setclassresources(3) about RLIMIT_VMM. Fixes: 1092ec8b3375 ("kern: Introduce RLIMIT_VMM") Reviewed by: bnovkov Differential Revision: https://reviews.freebsd.org/D57031
* bin/sh: make it possible to use as interactive initKonstantin Belousov2026-04-271-0/+19
| | | | | | | | | | | | | | | | If the /sbin/init binary is broken somehow, the way out is to set the loader environment variable init_path to something else. The most natural choice would be either /bin/sh or /rescue/sh. Unfortunately, this does not work because the init process starts withoud stdin/out descriptors. Make it nicer to users by teaching /bin/sh startup code to open standard descriptors on /dev/console if the shell is run as init. Reviewed by: imp, jilles, zlei Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56536
* sh: Allow vfork on redirected simple commandsJilles Tjoelker2026-04-251-3/+58
| | | | | | | | | | | | | | | | | Things like `{ some_program; } >/dev/null` use vfork, so use vfork similarly for things like `some_program >/dev/null`. This cannot be done for command substitutions, because of two problems: * Redirections might cause the error message for later redirections or for an unknown command to be sent to the pipe (to be substituted), and this might cause a deadlock if the message is too long. * The assignment of the pipe needs to come before instead of after the redirections. Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D55190
* freebsd-version(1): Disable pathname expansion in -j optionNami Arjmandi2026-04-221-2/+2
| | | | | | | | | | Set the -f flag to sh(1) to disable pathname expansion. Also, quote the jail variable to ensure correct behavior when passed to jexec(8). Signed-off-by: Nami Arjmandi <namiarjmandi@gmail.com> Reviewed by: pouria Pull-Request: https://github.com/freebsd/freebsd-src/pull/2158
* sh: Increase default history size to POSIX mandated minimum of 128Kristofer Peterson2026-04-131-1/+1
| | | | | | | | | | | | | | The default history size in bin/sh is currently 100 however POSIX.1-2024 mandates that a default greater than or equal to 128 shall be used, therefore this increases the default history size in /bin/sh to 128. POSIX standards reference: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sh.html#tag_20_110_08 MFC after: 3 days Reviewed by: emaste, jilles, jlduran, ziaee Signed-off-by: Kristofer Peterson <kris@tranception.com> Closes: https://github.com/freebsd/freebsd-src/pull/2093
* timeout.1: Document non-POSIX optionsArtem Bunichev2026-04-131-1/+5
| | | | | | MFC after: 3 days Reviewed by: Aaron Li <aly@aaronly.me>, ziaee Differential Revision: https://reviews.freebsd.org/D56090
* uuidgen: generate UUIDs in bounded batches to respect kernel limitNVSRahul2026-03-072-41/+44
| | | | | | | | | | | | | | | The uuidgen(2) system call enforces a hard upper limit of 2048 UUIDs per invocation. uuidgen(1) previously attempted to generate arbitrary counts in a single call and allocated memory accordingly, leading to EINVAL errors, unnecessary memory usage, and potential overflow risks. Generate UUIDs in fixed-size batches, streaming output incrementally while preserving existing semantics. Mirror the kernel limit explicitly since it is not exposed via a public interface. Signed-off-by: NVSRahul <nvsrahul@hotmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1965
* /bin/ps: Fix display of negative nice values on ARMv7/aarch64Jamie Landeg-Jones2026-03-073-2/+5
| | | | | | | | | | | | | | | | | | | | | | | On Arm-based systems (and maybe others), 'char' defaults to unsigned, causing negative nice values to be displayed incorrectly (e.g., 246 instead of -10). Explicitly using 'signed char' ensures consistent behaviour across architectures. [ tested on RPI2 and generic aarch64 qemu install ] Before: # /usr/bin/nice --10 ps -l | awk '(NR == 1 || $(NF-1) == "ps")' UID PID PPID C PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND 0 23606 22800 2 -32 246 5400 2544 - R<+ 0 0:00.06 ps -l After: # /usr/bin/nice --10 ps -l | awk '(NR == 1 || $(NF-1) == "ps")' UID PID PPID C PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND 0 23614 22800 3 -32 -10 5400 2544 - R<+ 0 0:00.05 ps -l Signed-off-by: Jamie Landeg-Jones <jamie@catflap.org> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/2064
* ed: add unicode support for the l (list) commandBaptiste Daroussin2026-03-012-18/+54
| | | | | | | | | | | | | | Use mbrtowc()/iswprint()/wcwidth() in put_tty_line() so that the l command displays valid multibyte characters as-is instead of escaping each byte as octal. Column wrapping now correctly accounts for character display width (including double-width CJK characters). Invalid or incomplete UTF-8 sequences and non-printable characters are still escaped as octal. Differential Revision: https://reviews.freebsd.org/D55365
* ed: add unicode test cases to ATF test suiteBaptiste Daroussin2026-03-011-0/+333
| | | | | | Including examples in Cyrillic suggested by kib@ Differential Revusion: https://reviews.freebsd.org/D55364
* sh.1: Add .sh_history and .shrc to FILESAlexander Ziaee2026-02-231-0/+4
| | | | | | MFC after: 3 days Reviewed by: bapt (previous), jilles, tembun@bk.ru Differential Revision: https://reviews.freebsd.org/D55295
* ed: convert test suite to ATF/kyuaBaptiste Daroussin2026-02-193-0/+1788
| | | | MFC After: 1 week
* sh.1: Reference editline(7)Artem Bunichev2026-02-181-3/+14
| | | | | | | | Key bindings for command line editing are documented in editline(7). MFC after: 3 days Reviewed by: jilles, ziaee Differential Revision: https://reviews.freebsd.org/D54767
* stty: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-189-0/+18
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55217
* sync: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-181-0/+2
| | | | | | Reviewed by: immp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55216
* sleep: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-181-0/+2
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55215
* sh: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-1822-0/+44
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55213
* setfacl: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-187-0/+14
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55212
* pwait: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-181-0/+2
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55211
* kenv: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-181-0/+2
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55210
* getfacl: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-181-0/+2
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55209
* ed: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-188-0/+16
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55208
* date: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-182-0/+4
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55207
* csh: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-182-0/+4
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55206
* sh.1: Fix ordering of Cm and Aq macrosArtem Bunichev2026-02-161-1/+1
| | | | | | | MFC after: 3 days Reviewed by: ziaee Fixes: 2711852bd9ac (sh.1: Provide detailed job control documentation) Differential Revision: https://reviews.freebsd.org/D55194
* sh.1: Document the exit status of returnArtem Bunichev2026-02-161-1/+5
| | | | | | | | | It's not obvious that if `exitstatus` is omitted, the exit status of the function is taken from the last executed command. MFC after: 3 days Reviewed by: jilles, ziaee Differential Revision: https://reviews.freebsd.org/D55026
* timeout: Clean upDag-Erling Smørgrav2026-02-132-85/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Annotate logv() and fix format string bug. * Don't reinvent str2sig(3). * Reorganize kill_self() so we unblock signals as late as possible, and use raise(2) instead of kill(2). * Explicitly close unused pipe descriptors. * Use correct type to collect result of read(2) and write(2). * Compare return values to 0, not -1. * Sort local variables according to style(9). * Reduce unnecessary nesting. * Reindent. * Fix typo in manual page. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D55277
* ls: check fts_children() for errors that may not surface otherwiseKyle Evans2026-02-112-0/+47
| | | | | | | | | | | | | | In particular, if one simply does a non-recursive `ls` on a directory that is not accessible, there are some classes of errors that may cause it to fail that wouldn't be surfaced unless we do an fts_read() that will recurse into the inaccessible directory. Catch those kinds of errors here since we cannot expect to an FTS_ERR/FTS_DNR entry to follow up on them. PR: 287451 Reviewed by: kib Discusssed with: des Differential Revision: https://reviews.freebsd.org/D51056
* cp: Expect EINTR while copyingDag-Erling Smørgrav2026-02-111-2/+5
| | | | | | | | | | | Both copy_file_range() and copy_fallback() can be interrupted before they have read anything at all, in which case they return -1 and set errno to EINTR. If that happens, we should retry, not fail. PR: 293028 MFC after: 1 week Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D55167
* pwd: Error out if writing to stdout failedDag-Erling Smørgrav2026-02-112-0/+23
| | | | | | | | | | POSIX requires us to print a diagnostic and return a non-zero exit code if writing to stdout failed. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55227
* pwd: Add testsDag-Erling Smørgrav2026-02-103-2/+83
| | | | | | MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D55153