History log of /src/bin/sh/tests/builtins/Makefile (Results 1 – 25 of 276)
Revision Date Author Comments
# 3c2643a7 19-Nov-2025 Dag-Erling Smørgrav <des@FreeBSD.org>

sh: Don't assume EINTR means SIGALRM

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 i

sh: Don't assume EINTR means SIGALRM

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

show more ...


# 75a6c38e 15-Nov-2025 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix a double free in a rare scenario with pipes

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

sh: Fix a double free in a rare scenario with pipes

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

show more ...


# 119fb2a2 02-Jul-2025 Xin LI <delphij@FreeBSD.org>

sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument

A script that does the following:

cd "${dir}" || exit 1

would incorrectly remain in the current directory when `${di

sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument

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

show more ...


# e9ac4169 15-Jul-2024 Warner Losh <imp@FreeBSD.org>

Remove residual blank line at start of Makefile

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


# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# 755a1be6 20-Aug-2022 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

sh: accept fc options grouped behind one '-'

As per Utility Syntax Guidelines, accept both forms: -l -n and -ln.

To do that, anticipate the source string for the next option that will
be parsed by

sh: accept fc options grouped behind one '-'

As per Utility Syntax Guidelines, accept both forms: -l -n and -ln.

To do that, anticipate the source string for the next option that will
be parsed by nextopt(). It's not always *argptr, sometimes it is
nextopt_optptr.

To simplify the check for not_fcnumber, slightly modify nextopt() to
always nullify nextopt_optptr in cases where it would have been set
to point to a NUL character.

Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D35836

show more ...


# e31fb971 23-May-2020 Bryan Drewery <bdrewery@FreeBSD.org>

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


# ccd0a51f 01-Sep-2020 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Write absolute path in command -vV and type

POSIX is pretty clear that command -v, command -V and type shall write
absolute pathnames. Therefore, we need to prepend the current directory's
name

sh: Write absolute path in command -vV and type

POSIX is pretty clear that command -v, command -V and type shall write
absolute pathnames. Therefore, we need to prepend the current directory's
name to relative pathnames.

This can happen either when PATH contains a relative pathname or when the
operand contains a slash but is not an absolute pathname.

show more ...


# 3c2643a7 19-Nov-2025 Dag-Erling Smørgrav <des@FreeBSD.org>

sh: Don't assume EINTR means SIGALRM

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 i

sh: Don't assume EINTR means SIGALRM

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

show more ...


# 75a6c38e 15-Nov-2025 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix a double free in a rare scenario with pipes

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

sh: Fix a double free in a rare scenario with pipes

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

show more ...


# 119fb2a2 02-Jul-2025 Xin LI <delphij@FreeBSD.org>

sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument

A script that does the following:

cd "${dir}" || exit 1

would incorrectly remain in the current directory when `${di

sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument

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

show more ...


# e9ac4169 15-Jul-2024 Warner Losh <imp@FreeBSD.org>

Remove residual blank line at start of Makefile

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


# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# 755a1be6 20-Aug-2022 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

sh: accept fc options grouped behind one '-'

As per Utility Syntax Guidelines, accept both forms: -l -n and -ln.

To do that, anticipate the source string for the next option that will
be parsed by

sh: accept fc options grouped behind one '-'

As per Utility Syntax Guidelines, accept both forms: -l -n and -ln.

To do that, anticipate the source string for the next option that will
be parsed by nextopt(). It's not always *argptr, sometimes it is
nextopt_optptr.

To simplify the check for not_fcnumber, slightly modify nextopt() to
always nullify nextopt_optptr in cases where it would have been set
to point to a NUL character.

Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D35836

show more ...


# e31fb971 23-May-2020 Bryan Drewery <bdrewery@FreeBSD.org>

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


# ccd0a51f 01-Sep-2020 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Write absolute path in command -vV and type

POSIX is pretty clear that command -v, command -V and type shall write
absolute pathnames. Therefore, we need to prepend the current directory's
name

sh: Write absolute path in command -vV and type

POSIX is pretty clear that command -v, command -V and type shall write
absolute pathnames. Therefore, we need to prepend the current directory's
name to relative pathnames.

This can happen either when PATH contains a relative pathname or when the
operand contains a slash but is not an absolute pathname.

show more ...


# 4600b569 15-Jul-2018 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Don't treat % specially in CDPATH


# 4d7f36ee 29-Apr-2018 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Don't have [ match any [[:class:]]

Submitted by: Robert Elz
MFC after: 3 days


# 531c2d7a 24-Jul-2017 Enji Cooper <ngie@FreeBSD.org>

MFhead@r320180


# bca9d05f 23-Jul-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Merge ^/head r319973 through 321382.


# a3604b95 27-Jun-2017 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r320042 through r320397.


# 6f49cd26 25-Jun-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Ignore error when cd writes the directory actually switched to.

If CDPATH is used non-trivially or the operand is "-", cd writes the
directory actually switched to. (We currently do this only in

sh: Ignore error when cd writes the directory actually switched to.

If CDPATH is used non-trivially or the operand is "-", cd writes the
directory actually switched to. (We currently do this only in interactive
shells, but POSIX requires this in non-interactive shells as well.)

As mentioned in Austin group bug #1045, cd shall not return an error while
leaving the current directory changed. Therefore, ignore any write error.

show more ...


# 209be205 16-May-2017 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r317971 through r318379.


# 1b21b7fa 14-May-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix '-' from quoted arithmetic in case/glob pattern range.

It does not make much sense to generate the '-' in a pattern bracket
expression using arithmetic expansion, but it does not make sense

sh: Fix '-' from quoted arithmetic in case/glob pattern range.

It does not make much sense to generate the '-' in a pattern bracket
expression using arithmetic expansion, but it does not make sense to forbid
it either.

Try to avoid reprocessing the string if it is unnecessary.

show more ...


# 73a73f7b 13-May-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add test for arithmetic expansion in [x-y] pattern range.

It does not make much sense to generate the '-' in a pattern bracket
expression using arithmetic expansion, but it does not make sense t

sh: Add test for arithmetic expansion in [x-y] pattern range.

It does not make much sense to generate the '-' in a pattern bracket
expression using arithmetic expansion, but it does not make sense to forbid
it either.

This test already passes.

show more ...


12345678910>>...12