Updated SC2294 (markdown)

Eisuke Kawashima
2025-07-29 10:39:46 +09:00
parent 4daacaa809
commit c95a7f1b97

@@ -33,7 +33,7 @@ Let's say you invoke `check sed -i '$d' "my file.txt"`:
Note that while `"$@"` is essentially always better than `eval "$@"`, it's easy to unintentionally introduce a dependency on bad behavior through the shell debugging anti-strategy of "adding quotes until it works":
```
```sh
# Works with problematic example because of double-escaping, fails with correct example
check ls -l "'My File.txt'"
@@ -47,7 +47,7 @@ The correct example is still better, but the function invocation has to be tweak
If each of the array elements is a carefully escaped shell command or word, use `*` instead of `@` to explicitly join the elements on spaces which is what would happen anyways:
```
```bash
on_exit=(
'rm /tmp/myfile; '
'echo "Finished on $(date)" > log.txt; '
@@ -66,7 +66,7 @@ done
If you require `eval` for another part of the command, explicitly transform the array into a series of escaped shell words. This ensures that the array elements will `eval` back to themselves:
```
```bash
# Assumed to be outside of our control,
# otherwise we would output this in an array as well:
COMMAND='dialog --menu "Choose file:" 15 40 4'