/bin/sh -- ${@:-stuff} expansion fix
This comes from the issue described in
https://mail-index.netbsd.org/pkgsrc-users/2026/11/19/msg043805.html
where pkgsrc/sysutils/sysupgrade was shown to behave differently
when using different shells to execute it.
The relevant code line is:
for set_name in "${@:-$(shtk_config_get SETS)}"; do
which intends to use "$@" (command line args, I think) if any are set, and the
results from:
shtk_config_get SETS
otherwise - intending that those results would be split into separate args.
There are a number of issues with this .. first the "${@:-...}" (and $* instead
[67 lines not shown]
tests/bin/sh/t_expand ... add test cases for ${@-word} (etc)
This usage (using the + - (also ? =) modifiers in parameter
expansions when the special parameter '@' (or '*') is being
expanded, is expressly left unspecified in the standard, and
applications should not attempt it - as different shells
produce different results.
Hence these new test case only run their sub-tests when the
shell being tested is the NetBSD shell - and are to verify
that that shell continues to produce sane (in our opinion)
results from these unspecified expansions, even if that might,
in some (or many) cases differ from what other shells do.
There are something around 350 new sub tests added (initially)
across the 4 new test cases -- those being to test the 4
major variations: "${@:-word}" "${@-word}" ${@:-word} ${@-word}
Each test case tests both the - and + operator. Note that it
is whether the $@ is quoted or not that matters, not whether
[13 lines not shown]
/bin/sh - minor DEBUG mode extension
This is a DEBUG mode only change, it does not affect any
shell built normally (nothing built by the NetBSD build
machinery) in any way -- the whole file being changed is
effectively #ifdef DEBUG and (in sh builds) DEBUG is
never defined (except by me, and perhaps, one day, someone
else.)
This adds a (trivial) mechanism to allow sh debug mode trace
files to be placed in some other directory than "." -- mostly
so it is possible to run a DEBUG compiled shell with debug
enabled while running ATF tests, without the trace file being
removed ("cleaned up") by ATF as soon as the test finishes.
NFC for any normal shell. Definitely no pullups.
/bin/sh - source code maintenance
KNF (including kreNF and 80-col police).
One grammar fix in a comment.
Some small DEBUG mode enhancements (more info dumped),
NFC for any normal shell. Definitely no pullups.
tests/bin/sh/t_expand.sh - minor cleanups (NMFC)
These changes make several minor changes to the layout
of the source file, more than anything else.
There are 3 kinds of changes (repeated throughout)
1. Use ' quoting rather than " quoting for the strings
used as the value of the ATF descr variable for each
test. This allows $ and " to be used in those strings
without requiring \ escaping, making them easier to read.
Also, drop meaningless leading/trailing spaces in these
strings, they don't use C string concat, which simply abuts
the contents of the strings, but more like sh "$*" which
puts spaces between the strings when joined into one.
2. Consistently write multi-line sh function definitions as
func_name()
{
[23 lines not shown]
src/tests/bin/sh - add a source code maintenance script
The sh tests contain many sets of tests which, when one fails, reports the
number of the test which failed (along with symptoms, actual code, ...) as
part of the failure log. Those numbers match numbers inserted as comments
with the tests, to allow the actual test to be more easily found (there tend
to be many which differ in just small details, hunting for the correct code
can be time consuming and error prone).
Until now, keeping those (comment) numbers correct has been a manual process,
itself almost as likely to fail as any of the tests the numbers are intended
to help identify.
This script (which has a very limited scope, just the shell ATF test sources
- and not even all, or even a majority, of those) will create a modified
version of the source code with all the comment numbers corrected. That
can then be compared with the unmodified version, and if all looks good,
replace it.
[14 lines not shown]
imx_ccm: split the core from the FDT glue
Move the FDT parts to imx_ccm_fdt.c so the core can be used without
fdt. composite set_rate now returns ENXIO when the parent is not found.
Tested on QEMU mcimx7d-sabre.
libc/strfmon - Partly revert previous
One of the changes was to some "half done" code that I had forgotten
when the recent changes were committed -- it worked fine as it was,
but was a bit odd ... the code was calling a func for parsing a string,
which would stop at the \0 which terminates it ... but the function
wanted to be told what the max number of bytes it was allowed to consume
would be, just in case there might be no \0. The original code
simply inserted an "easily big enough" constant - since the \0
wasn't ever going to be missing (string came from an earlier strdup()).
But, for other (related) reasons, the length of the string was being
calculated (strlen()) anyway - so rather than do that, and test it,
and then just throw away the length, the length could be captured,
and used instead of the constant. I had written the code (like, one
variable declaration, and an assignment ... not challenging) to
do that, but hadn't gotten around to using the value saved as the
arg to the function which could use it.
[23 lines not shown]
sys/dev/pci/arcmsr.c -- better fix than previous
Instead of converting a uint32_t * into an integer, doing int arith
on it, and then converting it back to a unit32_t * again, just do simple
pointer arithmetic on the unit32_t * (scaling the integer being added
by sizeof(unit32_t)).
This avoids errors: "cast to pointer from integer of different size"
uptrdiff_t (previous fix) would work, but just doing pointer arith
as it is intended to work is so much simpler & cleaner.
nb: compile tested only, I don't have that kind of hardware, nor do
I run 32 bit kernels.
Fix subnet mask extraction from address quad dot mask notation
when a rule has an address in 192.168.64.7/255.255.255.0
which is to be converted to block notation /24, it is expected
to reduce the count of trailing zeros from maximum masks for each family.
ensure the mask is set to max_mask to avoid it from crashing when using
that notation. also make noise when mask is bigger than expected.
/40 on a rule should make noise and not silently seg fault.
tests included in rump
reviewd by martin