Closed ryan-williams closed 1 month ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 90.03%. Comparing base (
9ac3b4a
) to head (8acd769
). Report is 1 commits behind head on main.
(R CI failure is unrelated, #2906)
Issue and/or context
#2218 (comment)
> `$"LD_LIBRARY_PATH"` evaluates to the string `LD_LIBRARY_PATH`; the `$` needs to be inside the quotes: > > ```bash > docker run --rm bash -c 'foo=1; echo $"foo" "$foo"' > # foo 1 > ``` > > `[ -z $"LD_LIBRARY_PATH" ]` is always false, so we've inadvertently been doing what @bkmartinjr suggested (always prepending `${tiledb}:`). I think this is also why the `set +u` seemed necessary; the "append" block was running even with `LD_LIBRARY_PATH` unset, which `set -u` was flagging as an error. > > A common way of doing these two `if` blocks is: > ```bash > export LD_LIBRARY_PATH="$tiledb${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" > export DYLD_LIBRARY_PATH="$tiledb${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" > ``` > cf. [SO](https://stackoverflow.com/a/46892074). This also works in `sh`: > ```bash > test() { > docker run --rm --entrypoint sh ubuntu -c "set -u; $1" > } > > test 'echo "prepended_val${foo:+:$foo}"' # `foo` unset > # prepended_val > test 'foo=; echo "prepended_val${foo:+:$foo}"' # `foo` empty > # prepended_val > test 'foo=val; echo "prepended_val${foo:+:$foo}"' # `foo` nonempty > # prepended_val:val > test 'echo "prepended_val${foo:+:}$foo"' # `foo` unset, and used outside `${foo:+…}` guard ⟹ `set -u` errors (as expected) > # sh: 1: foo: parameter not set > ``` > though I'd think this file's shebang line ensures we're always running `bash`.
Changes
Fix "
$
outside quotes" issue, replaceif
s with${var:+…}
, removeset +u
/set -u
:Use
echo
instead ofprintf
(per SC2059):