| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
When building without NO_ROOT, ${TAG_ARGS} is not set, which means we
pass ",config" as an install(1) argument. Only add the config tag if
${TAG_ARGS} is defined to begin with.
Fixes: aa730a66bc74 ("sh: Add config tag to /.profile")
Reported by: bz
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The file /.profile is installed as a hard link to /root/.profile. The
file in /root has the config tag, but the file in / does not, which
causes it to be overwritten by pkg upgrade. Since they're linked, this
also overwrites the file in /root.
Add the config tag to the file in / as well, so pkg treates both links
as config files and won't overwrite them.
PR: 289097
MFC after: 3 days
Reviewed by: bapt, emaste
Differential Revision: https://reviews.freebsd.org/D52162
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A script that does the following:
cd "${dir}" || exit 1
would incorrectly remain in the current directory when `${dir}` is
an empty string under the current implementation. This behavior,
while historical, is potentially dangerous, as it is likely not
what the script author intended.
Change the command to treat an empty string as an error and emit a
diagnostic message to standard error, as required by
IEEE Std 1003.1-2024.
PR: standards/287440
Test Plan: kyua test bin/sh
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D50974
|
| |
|
|
|
|
|
|
|
|
| |
MALLOC_OPTIONS=J -> MALLOC_CONF=junk:true
PR: 287357
Reviewed by: markj
Event: Kitchener-Waterloo Hackathon 202506
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50910
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If run as
alias ''
uninitialized memory could be referenced.
This is based on a fix from NetBSD. For more information, refer to
https://github.com/NetBSD/src/commit/10cfed82c28 .
Obtained from: NetBSD (Robert Elz <kre@netbsd.org>, 10cfed82c28)
MFC after: 3 days
Reported by: mckusick, Robert Elz <kre@netbsd.org>
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50364
|
| |
|
|
|
|
| |
Remove the double word "the the" from the sh(1) manual page.
MFC after: 3 days
|
| |
|
|
|
|
|
| |
Jump from one word to another. Not words to words.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1565
|
| |
|
|
|
|
|
|
|
| |
This partially reverts b14cfdf665bb8b7b2898a4ee5b073ab87f8ea3d0 and has
been discussed in D42719.
Reviewed by: jrm (mentor), otis (mentor), mandree, ziaee (manpages)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D45073
|
| |
|
|
|
|
|
|
|
|
| |
Provide more details about the influence of optargs' first character
on the shell's behavior in regard to invalid arguments. Also do some
minor word-smithing.
Original submission by rea@
Differential Revision: https://reviews.freebsd.org/D49106
|
| |
|
|
|
|
|
|
|
|
|
| |
TIL the `:` command accepts and discards arguments, and this is
occasionally used to embed comments in interesting places. While
here, fix another `...` argument that was not marked up.
MFC after: 3 days
Thanks: Community Discord
Approved by: carlavilla, mhorne (mentors)
Differential Revision: https://reviews.freebsd.org/D48398
|
| |
|
|
|
|
|
|
|
|
|
|
| |
+ increase history consistency by adding "first appeared"
+ remove a skipped new paragraph macro to quiet linter
+ tag spdx
MFC after: 3 days
History source: www.in-ulm.de/~mascheck/various/ash/#bsd
Reviewed by: mhorne,imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1440
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
-l is required by LSB for login shell, all other shells: bash, zsh,
oksh, mksh, ... implements it.
with -l sh will act as a login shell and read the profile.
MFC After: 1 week
Obtained From: dash (3b7c8442bfe7c2fd0a6b0415df6ddf66a399fd55)
Reviewed by: kib, lme
Differential Revision: https://reviews.freebsd.org/D47681
|
| |
|
|
|
|
|
|
|
|
| |
Some sh tests use ktrace to see whether a particular file, specified in
the environment, was accessed by the shell. After commit 65a4daeaf324,
this test matches the ktrace record generated by execve.
Use ktrace to only log name lookups, to avoid such false matches.
Fixes: 65a4daeaf324 ("ktrace: log execve(2) arguments and environment")
|
| |
|
|
|
|
|
| |
After building packages we have a number of new
and updated Makefile.depend files
Reviewed by: stevek
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The intended value is:
-offset indent
If there's any typo such that the value doesn't match the pre-defined
strings, then the offset is the same width as the value. So by chance,
"-offset -ident" ended up being a standard-width indent (since the
default indent is 6 chars, and "-ident" also has 6 chars), whereas
"-offset -indent" had a longer indent, and "-offset ident" had a shorter
one.
Signed-off-by: Graham Percival <gperciva@tarsnap.com>
Reviewed by: mhorne, Alexander Ziaee <concussious.bugzilla@runbox.com>
MFC after: 3 days
Sponsored by: Tarsnap Backup Inc.
Pull Request: https://github.com/freebsd/freebsd-src/pull/1436
|
| |
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D46619
|
| |
|
|
|
|
|
| |
This is a residual of the $FreeBSD$ removal.
MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
|
| |
|
|
|
| |
Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request: https://github.com/freebsd/freebsd-src/pull/992
|
| |
|
|
|
|
|
|
| |
Remove extra 'ing' from 'bookinging.'
Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/934
|
| |
|
|
|
|
| |
Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, @rilysh on github
Pull Request: https://github.com/freebsd/freebsd-src/pull/935
|
| |
|
|
|
|
|
|
| |
nozero -> non-zero
Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/936
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.
Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
| |
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
| |
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
According to /etc/mtree/BSD.root.dist /root should have
0750 permissions, but the build target 'make installworld'
changes these to 0755.
This is caused by the installation of the configuration
files of sh(1) and csh(1).
Correct this by specifying the correct default /root permissions.
PR: 273342
Reviewed by: jilles
Approved by: jilles
MFC after: 2 weeks
Differential Revision:https://reviews.freebsd.org/D42395
|
| |
|
|
|
|
|
|
|
|
| |
\D{format} yields the result of calling strftime(3) with the provided
format and the current time.
When PS4 can use this, it will enable us to easily generate timestamps
when tracing script execution.
Differential Revision: https://reviews.freebsd.org/D35840
|
| |
|
|
| |
Differential Revision: https://reviews.freebsd.org/D40619
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
While aliases and built-ins are opportunistically stored in cmdtable, each
function will be added to it immediately on definition.
Factor out the hashing function, write the iterator function and make it use
the hashing function.
Add the cmdname pointer to struct cmdentry so that the command name can be
exposed that way.
Differential Revision: https://reviews.freebsd.org/D40619
|
| |
|
|
| |
Differential Revision: https://reviews.freebsd.org/D40619
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently the data structure holding alias information is opaque for
consumers outside alias.c and there is no way to iterate over all
aliases, which will become needed by a future commit.
The new function "iteralias" takes a null pointer to return the first
alias or an existing alias to return the next one, unless there is
no alias to return, in which case it returns a null pointer.
I slightly changed the static function hashalias so that it returns the
index into the array holding link heads, and not the link head directly.
In this form it's easier to use by iteralias and the slight adjustment
in the three existing callers doesn't look too bad.
Differential Revision: https://reviews.freebsd.org/D40619
|
| |
|
|
|
|
|
| |
Reduce indentation level before a commit that will add new code here.
Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D37926
|
| |
|
|
| |
Fixes: d0b2dbfa0ecf ("Remove $FreeBSD$: one-line sh pattern")
|
| |
|
|
| |
Remove /^\.\\"\s*\$FreeBSD\$$\n/
|
| |
|
|
| |
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
|
| |
|
|
| |
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| |
|
|
| |
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
|
| |
|
|
| |
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
| |
|
|
|
|
|
|
|
| |
When generated files depend on tools that need to be built for host,
we need to carefully separate them for the DIRDEPS_BUILD so we
only build them once.
Reviewed by: stevek
Sponsored by: Juniper Networks, Inc.
|
| |
|
|
|
|
|
|
| |
Reported in a comment in PR 261728.
Reported by: Oleg
Reviewed by: jilles (previous version), bapt
Differential Revision: https://reviews.freebsd.org/D39839
|
| |
|
|
|
|
|
|
| |
We are modifying it after setjmp and then accessing it after the jump,
so it cannot be a local.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40415
|
| |
|
|
|
|
|
|
|
|
|
| |
As popstackmark may be called on this without pushstackmark having
been called, we need to initialize it so that we don't get a bogus
comparison inside popstackmark, which would have resulted in a
NULL pointer dereference.
MFC After: 3 days
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D40413
|