aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* ed: add unicode support for the l (list) commandBaptiste Daroussin6 days2-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 Daroussin6 days1-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 Ziaee12 days1-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
* pwd: Clean up and adopt POSIX semanticsDag-Erling Smørgrav2026-02-102-49/+54
| | | | | | | | | | | | | | According to POSIX, the default should be -L. Based on code history, whoever first wrote BSD pwd(1) could not figure out how to implement -L and therefore made -P the default (and only) option. Support for -L was later added, but the default was never changed. Clean up the code, make -L the default, and rewrite getcwd_logical() to reject paths that contain dot or dot-dot, as required by POSIX. MFC after: 1 week Reviewed by: olce Differential Revision: https://reviews.freebsd.org/D55146
* chio: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-093-0/+6
| | | | | | | | | Some BSD-4-Clause files under bin/chio were missing the SPDX-License-Identifier-tag. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55193
* sh.1: Fix rendering error due to redundant .ElArtem Bunichev2026-02-031-2/+1
| | | | | | | | | | Due to this all the rest of the items in the Built-in Commands section were not rendered at all. Fixes: 2711852bd9ac ("sh.1: Provide detailed job control documentation") MFC after: 3 days Reviewed by: emaste, ziaee Differential Revision: https://reviews.freebsd.org/D55080
* sh.1: Provide detailed job control documentationArtem Bunichev2026-01-291-9/+182
| | | | | | | | Adopt the POSIX standard text to our implementation. PR: 206284 Reviewed by: des, jilles, ziaee Differential Revision: https://reviews.freebsd.org/D49895
* symlink.7: add a new section "mount options"Wolfram Schneider2026-01-191-2/+19
| | | | | | | Add a new section "mount options" to explain the mount option nosymfollow in more details. Differential Revision: https://reviews.freebsd.org/D54530
* df: Fix -k flag consistency with other BLOCKSIZE flagsAnkush Mondal2026-01-091-4/+5
| | | | | | | | | | | | | | | | | | | | This patch resolves inconsistent behavior between the -k option and other related flags, including -P. Previously, using -k resulted in output displayed in 1024-byte blocks, which did not align with the behavior of similar options such as -m and -g, where output is shown in 1M-blocks and 1G-blocks respectively. The updated implementation ensures that -k now correctly displays sizes in 1K-blocks. In addition, the patch incorporates the POSIX requirement that when both -k -P are specified, the block size must be explicitly forced to 1024-blocks. Together, these changes make the behavior of -k consistent, predictable, and compliant with the standard. Signed-off-by: Ankush Mondal <mondalankush9851@gmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1906
* ps(1): Sort headersOlivier Certner2026-01-092-5/+5
| | | | | | | | | | Found these changes by chance in an old patch file. Should have been committed along with the ps(1) modifications done in March 2025. No functional change (intended). MFC after: 3 days Sponsored by: The FreeBSD Foundation
* sh.1: Restore missing builtin commandsAlexander Ziaee2026-01-061-1/+1
| | | | | | PR: 292221 Fixes: 2980318b2747 (sh.1: extend the section about getopts) MFC after: 3 days
* sh: avoid warnings about too-long initializer stringsDimitry Andric2025-12-272-2/+2
| | | | | | | | | | | | | | | | Mark `optletter` and `t_op::op_text` as `__non_string`, to avoid warnings from clang 21 similar to: bin/sh/options.h:77:36: error: initializer-string for character array is too long, array size is 19 but initializer has size 20 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization] 77 | const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh"; | ^~~~~~~~~~~~~~~~~~~~~ bin/test/test.c:153:3: error: initializer-string for character array is too long, array size is 2 but initializer has size 3 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization] 153 | {"==", STREQ}, | ^~~~ MFC after: 3 days Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D54362
* cp: Fix copying the root directoryDag-Erling Smørgrav2025-11-222-1/+21
| | | | | | | | | | | | When the source of the copy operation is the root directory, we should neither append it to the destination path on FTS_D nor trim it back off on FTS_DP. PR: 291132 MFC after: 3 days Fixes: 82fc0d09e862 ("cp: Partly restore symlink folllowing.") Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D53863
* sh: Fix job pointer invalidation with trapsasyncJilles Tjoelker2025-11-193-1/+15
| | | | | | | | | | | Calling dotrap() can do almost anything, including reallocating the jobtab array. Convert the job pointer to an index before calling dotrap() and then restore a proper job pointer afterwards. PR: 290330 Reported by: bdrewery Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D53793
* sh: Don't assume EINTR means SIGALRMDag-Erling Smørgrav2025-11-195-29/+112
| | | | | | | | | | | | | | | | | | | | | | | | | While waiting for input in the read builtin, if select() is interrupted but there is no pending signal, we act like we timed out, and return the same status as if we had been interrupted by SIGALRM, instead of looping until we actually do time out. * Replace the single select() call with a ppoll() loop. * Improve validation of the timeout value. We now accept things like "1h30m15s", which we used to silently truncate to "1h". The flip side is that we no longer accept things like "1hour" or "5sec". * Modify the existing `read -t 0` test case to verify that read returns immediately when there is input and fails immediately when there isn't. * Add a second test case which performs the same tests with a non-zero timeout value. PR: 290844 MFC after: 1 week Fixes: c4539460e3a4 ("sh: Improve error handling in read builtin:") Reviewed by: jilles, bdrewery Differential Revision: https://reviews.freebsd.org/D53761
* sh: Fix a double free in a rare scenario with pipesJilles Tjoelker2025-11-173-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The command sh -c 'sleep 3 | sleep 2 & sleep 3 & kill %1; wait %1' crashes (with appropriate sanitization such as putting MALLOC_CONF=abort:true,junk:true in the environment or compiling with -fsanitize=address). What happens here is that waitcmdloop() calls dowait() with a NULL job pointer, instructing dowait() to freejob() if it's a non-interactive shell and $! was not and cannot be referenced for it. However, waitcmdloop() then uses fields possibly freed by freejob() and calls freejob() again. This only occurs if the job being waited for is identified via % syntax ($! has never been referenced for it), it is a pipeline with two or more elements and another background job has been started before the wait command. That seems special enough for a bug to remain. Test scripts written by Jilles would almost always use $! and not % syntax. We can instead make waitcmdloop() pass its job pointer to dowait(), fixing up things for that (waitcmdloop() will have to call deljob() if it does not call freejob()). The crash from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=290330#c2 appears to be the same bug. PR: 290330 Reported by: bdrewery Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D53773
* date: Improve nanosecond supportDag-Erling Smørgrav2025-11-113-53/+147
| | | | | | | | | | | | | Add support for a field width, which defaults to 9 if unspecified or zero. If the width is not exactly 9, we have to either cut off digits or append zeroes to make up the difference. If the width is a dash, we pick a width based on the clock's reported resolution. This brings us in line with GNU coreutils. PR: 287080 MFC after: 1 week Reviewed by: 0mp Differential Revision: https://reviews.freebsd.org/D53667
* rm(1): remove whiteouts when forcibly removing directoriesJason A. Harmening2025-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | Commit 2ed053cde5 changed UFS' VOP_RMDIR() behavior to no longer ignore whiteouts when determining whether a directory is empty, unless explicitly requested by the caller. However, this also necessitates a change to rm(1) to avoid breaking the expected behavior when forcibly removing directory hierarchies via `rm -fr`. I neglected to make this follow-on change despite discussing it in the review for the breaking commit (D45987). Finally address the breakage by making `rm -fr` imply FTS_WHITEOUT when rm(1) reads directory contents via fts_read(3). While here, also fix a logic error which produces a spurious 'No error' warning message on stdout for each deleted whiteout. Reported by: csjp Reviewed by: csjp, kib, olce MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53640
* sh: Implement simple parameter expansion in PS1 and PS2Matthew Phillips2025-11-078-1/+181
| | | | | | | | | | This change follows a localized approach within getprompt() and avoids full parser reentry. While this means we don't support advanced expansions like ${parameter#pattern}, it provides POSIX-compliant basic parameter expansion without the complexity of making the parser reentrant. This is sufficient for the vast majority of use cases. PR: 46441
* sh tests: Fix racy test11.0Bryan Drewery2025-11-071-2/+2
| | | | | | | | | This was sometimes exiting while the child fifo was created resulting in [ENOTEMPTY] from rm. The child fifo isn't needed, just sleep. PR: 290837 Fixes: e31fb97148f ("read builtin: Empty variables on timeout") MFC after: 3 days
* date.1: Lint with mandocMateusz Piotrowski2025-11-051-17/+18
| | | | | | | | | | Specifically, remove Tn macors, replace Li with Ql, and escape %N to address date.1's rendering issues on man.freebsd.org. PR: 290801 Reported by: jinwookjeongg@gmail.com MFC after: 1 week Sponsored by: Klara, Inc.
* pwait: Add an option to print remaining processesDag-Erling Smørgrav2025-10-283-35/+107
| | | | | | | | | | | * On startup, insert all valid PIDs into a tree. * In our main loop, whenever a process terminates, remove its PID from the tree. * On exit, if the -p flag was specified, print the remaining PIDs. MFC after: 3 days Reviewed by: bcr, markj Differential Revision: https://reviews.freebsd.org/D53293
* pwait: Avoid calling getpid(2) for each proc.Bryan Drewery2025-10-241-1/+3
|
* ln: Simplify sameness checksDag-Erling Smørgrav2025-10-071-1/+1
| | | | | | Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D52927
* cp: Simplify sameness checksDag-Erling Smørgrav2025-10-071-4/+4
| | | | | | Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D52926
* bin/sh: Fix the buildLexi Winter2025-09-301-0/+2
| | | | | | | Removing <bsd.prog.mk> was unintentional; put it back. Fixes: d31e342bcc8e ("sh: Remove /.profile") MFC after: 1 day
* sh: Remove /.profileLexi Winter2025-09-301-9/+0
| | | | | | | | | | | | | root's home directory was moved to /root many years ago, so there's no reason to keep this old link. This brings sh in line with csh, where /.cshrc was removed in dcb65c5a94d4. Relnotes: yes Approved by: re (cperciva) MFC after: 1 day PR: 289097 Reviewed by: cperciva, jilles, bapt, emaste Differential Revision: https://reviews.freebsd.org/D52161
* pwait: Fix timeout unit parserDag-Erling Smørgrav2025-09-231-12/+18
| | | | | | | | | | | The timeout parser would check the first character after the number and ignore any subsequent ones. While here, switch to bool for booleans and fix some style nits. MFC after: 1 week Reviewed by: 0mp, markj Differential Revision: https://reviews.freebsd.org/D52612
* init: Use root's home directory in single-user modeJilles Tjoelker2025-09-161-2/+0
| | | | | | | | | | | | | | | | | When starting single-user mode, use the home directory from user root as current directory and for the HOME environment variable. If the directory does not exist, set HOME=/. Also adjust /root/.profile to stop setting HOME, since it should always have been set now. This is intended to keep shell startup files working in single-user mode after /.profile has been removed. Reviewed by: emaste, ivy, kevans MFC after: 1 week Relnotes: yes Differential Revision: https://reviews.freebsd.org/D52527
* cp: Drop test helperDag-Erling Smørgrav2025-09-163-76/+1
| | | | | | | | | Now that stat(1) can report whether a file is sparse, we no longer need a helper program for our tests. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D52482