<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/bin/sh, branch stable/13</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=stable%2F13</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=stable%2F13'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2026-02-01T14:35:59Z</updated>
<entry>
<title>sh: Fix job pointer invalidation with trapsasync</title>
<updated>2026-02-01T14:35:59Z</updated>
<author>
<name>Jilles Tjoelker</name>
<email>jilles@FreeBSD.org</email>
</author>
<published>2025-11-17T17:42:01Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=e45b89582fcbf4f65593303bf41a28ed6071460f'/>
<id>urn:sha1:e45b89582fcbf4f65593303bf41a28ed6071460f</id>
<content type='text'>
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

(cherry picked from commit f44ac8cc9c10d7305223a10b8dbd8e234388cc73)
</content>
</entry>
<entry>
<title>sh: Fix a double free in a rare scenario with pipes</title>
<updated>2026-02-01T14:35:54Z</updated>
<author>
<name>Jilles Tjoelker</name>
<email>jilles@FreeBSD.org</email>
</author>
<published>2025-11-15T16:43:03Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=b9cdb4d34bc4ea0093597f2bc4a86ce6ed5ab569'/>
<id>urn:sha1:b9cdb4d34bc4ea0093597f2bc4a86ce6ed5ab569</id>
<content type='text'>
The command
  sh -c 'sleep 3 | sleep 2 &amp; sleep 3 &amp; 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

(cherry picked from commit 75a6c38e4d5c651b7398bf2bea5baa41a0939e92)
</content>
</entry>
<entry>
<title>sh: avoid warnings about too-long initializer strings</title>
<updated>2026-01-02T20:49:46Z</updated>
<author>
<name>Dimitry Andric</name>
<email>dim@FreeBSD.org</email>
</author>
<published>2025-12-25T20:13:48Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=3015ca9407d14876b1b6e8babc5b94acd939af68'/>
<id>urn:sha1:3015ca9407d14876b1b6e8babc5b94acd939af68</id>
<content type='text'>
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

(cherry picked from commit e6546807f4c1a8a6a6fa53fceab7b8c80e3ed802)
</content>
</entry>
<entry>
<title>sh(1): Replace recommendation of use of -e with a note</title>
<updated>2025-03-15T14:01:42Z</updated>
<author>
<name>Michael Osipov</name>
<email>michaelo@FreeBSD.org</email>
</author>
<published>2024-05-03T07:57:06Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=61df1b78f90681c015fade9b81b40ae1f379e1df'/>
<id>urn:sha1:61df1b78f90681c015fade9b81b40ae1f379e1df</id>
<content type='text'>
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

(cherry picked from commit 7bd8da72c5814b486ae7f492286fe3ac0a5bf03d)
</content>
</entry>
<entry>
<title>sh.1: update history + spdx + linter error</title>
<updated>2024-12-28T18:17:14Z</updated>
<author>
<name>Alexander Ziaee</name>
<email>concussious@runbox.com</email>
</author>
<published>2024-09-29T08:14:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=6a03eb1f3028a96a031bf11b2567540b0e9b7f5e'/>
<id>urn:sha1:6a03eb1f3028a96a031bf11b2567540b0e9b7f5e</id>
<content type='text'>
+ 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

(cherry picked from commit e2a72442bd57c1373c30fab945fbfc86464f3782)
</content>
</entry>
<entry>
<title>sh(1): -l is only valid in cli option not as set -l</title>
<updated>2024-12-12T16:02:48Z</updated>
<author>
<name>Baptiste Daroussin</name>
<email>bapt@FreeBSD.org</email>
</author>
<published>2024-11-20T13:14:43Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=1e502fc1c4215ac61db04598eb0a15d0e1ff7d6a'/>
<id>urn:sha1:1e502fc1c4215ac61db04598eb0a15d0e1ff7d6a</id>
<content type='text'>
(cherry picked from commit 0df81552d74d2c188a9323ffe18f6ebe799b86f9)
</content>
</entry>
<entry>
<title>sh(1): add -l option</title>
<updated>2024-12-12T16:02:48Z</updated>
<author>
<name>Baptiste Daroussin</name>
<email>bapt@FreeBSD.org</email>
</author>
<published>2024-11-20T10:48:39Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=6e1b857b89d4e22fe711eef45e2e32e6b6606a0b'/>
<id>urn:sha1:6e1b857b89d4e22fe711eef45e2e32e6b6606a0b</id>
<content type='text'>
-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

(cherry picked from commit 65f5dd42f11cdcb7716e6cdd09fac2314c144c1f)
</content>
</entry>
<entry>
<title>sh(1): add -l option</title>
<updated>2024-12-12T16:00:48Z</updated>
<author>
<name>Baptiste Daroussin</name>
<email>bapt@FreeBSD.org</email>
</author>
<published>2024-11-20T10:48:39Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=973a9a36fd56fefa44ce2ab22eb67bb2077c1f84'/>
<id>urn:sha1:973a9a36fd56fefa44ce2ab22eb67bb2077c1f84</id>
<content type='text'>
-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

(cherry picked from commit 65f5dd42f11cdcb7716e6cdd09fac2314c144c1f)
</content>
</entry>
<entry>
<title>Fix /root permissions after 'make installworld'</title>
<updated>2023-12-01T07:16:38Z</updated>
<author>
<name>Thomas Eberhardt</name>
<email>sneakywumpus@gmail.com</email>
</author>
<published>2023-11-16T09:59:38Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=1023abd5b60f82360ea9f09b9af06dd30d6d8c18'/>
<id>urn:sha1:1023abd5b60f82360ea9f09b9af06dd30d6d8c18</id>
<content type='text'>
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

(cherry picked from commit a6ed8c9593031abf6fa73661be55c226caa362d6)
</content>
</entry>
<entry>
<title>sh tests: Update $LINENO tests after $FreeBSD$ removal</title>
<updated>2023-08-23T17:45:13Z</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2023-08-23T17:24:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c1c798f174817b567f66379412c231ebfdcd7c8b'/>
<id>urn:sha1:c1c798f174817b567f66379412c231ebfdcd7c8b</id>
<content type='text'>
Fixes:	d0b2dbfa0ecf ("Remove $FreeBSD$: one-line sh pattern")
(cherry picked from commit c903f664780e2df7aff9ca84089d55dec5ff1dae)
</content>
</entry>
</feed>
