From c95a7f1b976aa3f32c1512f791c30d0c2fc9c652 Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Tue, 29 Jul 2025 10:39:46 +0900 Subject: [PATCH] Updated SC2294 (markdown) --- SC2294.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SC2294.md b/SC2294.md index b3b45f7..ae06680 100644 --- a/SC2294.md +++ b/SC2294.md @@ -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'