For the following code, I'm getting SC2089 "Quotes/backslashes will be treated literally, use an array"
# Quotes/backslashes will be treated literally, use an array
CMD_AVAIL_MSG='%s is required for this script but the "%s" command is missing. Exiting...'
if [ -z "$(which valet)" ]; then
printf -v err $CMD_AVAIL_MSG "Laravel Valet" "valet";
echo $err; # there's other stuff I do here, but using echo for conciseness
exit 1;
fi
However, converting this to an array gives me shellcheck warning SC2059 "Don't use variables in the printf format string, use '...%s...' $foo"
CMD_AVAIL_MSG=("%s" 'is required for this script but the "' '%s' '" command is missing. Exiting...')
if [ -z "$(which valet)" ]; then
# Don't use variables in the printf format string, use '...%s...' "$foo"
printf -v err "${CMD_AVAIL_MSG[@]}" "Laravel Valet" "valet";
echo $err; # there's other stuff I do here, but using echo for conciseness
exit 1;
fi
How do I resolve both of these warnings?