Development record
The colon test of ${@:-w}, ${*:-w}, ${@:=w} and ${@:?} is taken on the parameter count, not on a joined value, but the guard read them as a single empty parameter does (the empty value never printed), a regression from iss-2609300651127327. With set -- "" "" (a script called as clean.sh "" "") bash 3.2, /bin/sh, dash and bash 5.3 hand rm the home for rm -rf $HOME${@:-x} and $HOME${*:?}, and / or /* for rm -rf ${@:-x}/*, ${*:-x}/ and ${@:?}/; all were allowed.
issueresolvedmajoriss-2609300726419415
The colon test of ${@:-w}, ${:-w}, ${@:=w} and ${@:?} is taken on the parameter count, not on a joined value, but the guard read them as a single empty parameter does (the empty value never printed), a regression from iss-2609300651127327. With set -- "" "" (a script called as clean.sh "" "") bash 3.2, /bin/sh, dash and bash 5.3 hand rm the home for rm -rf $HOME${@:-x} and $HOME${:?}, and / or /* for rm -rf ${@:-x}/, ${:-x}/ and ${@:?}/; all were allowed.
Grounds
- pursued: ${@:-x}/, ${@:-x}/, ${:-x}/, ${@:?}/, ${:=x}/, $HOME${@:-x} and $HOME${:?} block bare, in bash -c and in sh -c, while ${1:-dist}/ stays allowed; a shell that printed dist/ for ${@:-x}/ after set -- "" "" would show it wrong
Frontmatter
| id | iss-2609300726419415 |
|---|---|
| type | issue |
| lifecycle | resolved |
| severity | major |
.abcd/work/issues/resolved/iss-2609300726419415-the-colon-test-of-w-w-w-and-is-taken-on.md
open on GitHub ↗ · commit history ↗
mentions1
- iss-2609300651127327rm-rf-root-or-home over-blocks an everyday clean line: `rm -rf "${1:-build}"/*`, `rm -rf ${1:-dist}/`, `rm -rf "${1:-dist}/"*` and `rm -rf ${@:-x}/` block, and `rm -rf ./${1:-dist}` warns, though no shell prints the empty value under `:-`. The empty text an emptyable parameter can print was kept under the colon operators.