diff --git a/SC2046.md b/SC2046.md index 1906172..dbe8e67 100644 --- a/SC2046.md +++ b/SC2046.md @@ -41,9 +41,11 @@ This is because `pkg-config` outputs `-lssl -lcrypto`, which you want to break u A bash alternative in these cases is to use `read -a` for words or `mapfile` for lines. ksh can also use `read -a`, or a `while read` loop for lines. In this case, since `pkg-config` outputs words, you could use: ```sh -# Read words into an array in bash and ksh +# Read words from one line into an array in bash and ksh, then expand each as args read -ra args < <(pkg-config --libs openssl) +gcc "${args[@]}" client.c # expand as args -# expand args -gcc "${args[@]}" client.c +# Read lines into an array, then expand each as args +readarray -t file_args < <(find /etc/ -type f | grep some-check) +your-linter.sh "${file_args[@]}" # expand as args ``` \ No newline at end of file