| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
Including examples in Cyrillic suggested by kib@
Differential Revusion: https://reviews.freebsd.org/D55364
|
| |
|
|
|
|
| |
MFC after: 3 days
Reviewed by: bapt (previous), jilles, tembun@bk.ru
Differential Revision: https://reviews.freebsd.org/D55295
|
| |
|
|
| |
MFC After: 1 week
|
| |
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55217
|
| |
|
|
|
|
| |
Reviewed by: immp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55216
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55215
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55213
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55212
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55211
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55210
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55209
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55208
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55207
|
| |
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55206
|
| |
|
|
|
|
|
| |
MFC after: 3 days
Reviewed by: ziaee
Fixes: 2711852bd9ac (sh.1: Provide detailed job control documentation)
Differential Revision: https://reviews.freebsd.org/D55194
|
| |
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D55153
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
| |
Adopt the POSIX standard text to our implementation.
PR: 206284
Reviewed by: des, jilles, ziaee
Differential Revision: https://reviews.freebsd.org/D49895
|
| |
|
|
|
|
|
| |
Add a new section "mount options" to explain
the mount option nosymfollow in more details.
Differential Revision: https://reviews.freebsd.org/D54530
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
PR: 292221
Fixes: 2980318b2747 (sh.1: extend the section about getopts)
MFC after: 3 days
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
* 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
|
| | |
|
| |
|
|
|
|
| |
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D52927
|
| |
|
|
|
|
| |
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D52926
|
| |
|
|
|
|
|
| |
Removing <bsd.prog.mk> was unintentional; put it back.
Fixes: d31e342bcc8e ("sh: Remove /.profile")
MFC after: 1 day
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
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
|