[INFRA]: Declaration commands mask return values in CI scripts (SC2155)
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
### Is this a duplicate?
- [x] I have searched the [open issues](https://github.com/NVIDIA/cccl/issues) and this is not a duplicate
### Overview
76 sites across 37 CI scripts combine variable declaration (`local`, `readonly`, or `export`) with command substitution on the same line. The exit code of the command substitution is masked by the declaration keyword (which always returns 0).
All affected scripts use `set -euo pipefail`. Combining declaration with substitution silently defeats that intent — if the command fails, the script continues with an empty or partial value instead of aborting.
### Details
**Pattern:**
```bash
# Current — if cd fails, $? is still 0 due to readonly:
readonly ci_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Fixed — command failure is visible to set -e:
ci_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly ci_dir
```
Same applies to `local` and `export`:
```bash
# local:
local start_time
start_time=$(date +%s)
# export:
CXX="$(which g++)"
export CXX
```
**Scope:**
| Pattern | Count | Files |
|---------|-------|-------|
| `readonly var="$(cmd)"` | ~55 | ci/util/artifacts/\*.sh, ci/util/workflow/\*.sh, ci/upload_\*.sh |
| `local var="$(cmd)"` | ~15 | ci/pretty_printing.sh, ci/util/memmon.sh, ci/pyenv_helper.sh |
| `export var="$(cmd)"` | ~3 | ci/build_cuda_cccl_wheel.sh |
| `readonly var=$(cat <
Contributor guide
Assessment
This issue has not been assessed yet.