-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Double quote variables to prevent globbing and word splitting #17235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for doing this!
This change goes through and quotes variables where appropriate to avoid issues with incorrect splitting. The performance tests ran into an issue with $SUDO_COMMAND splitting incorrectly because it was not quoted. This change fixes that issue and hopefully gets ahead of any other similar problems. Signed-off-by: Aleksandr Liber <[email protected]> Requires-builders: test perf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a shell guru, but some things look suspicious to me.
@@ -105,7 +105,7 @@ function do_fio_run_impl | |||
# the default filesystem (e.g. against a clone). | |||
# | |||
export DIRECTORY=$(get_directory) | |||
log_note "DIRECTORY: " $DIRECTORY | |||
log_note "DIRECTORY: " "$DIRECTORY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think log_note
cares about number of arguments, but if we want to wrap the variable into quotes, I don't think we need to close and reopen them before it.
|
||
# Define output file | ||
typeset logbase="$(get_perf_output_dir)/$(basename \ | ||
$SUDO_COMMAND)" | ||
"$SUDO_COMMAND")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you are adding quotes inside quotes. Doesn't it need escaping, or something?
typeset outfile="$logbase.fio.$suffix" | ||
|
||
# Start the load | ||
if [[ $NFS -eq 1 ]]; then | ||
log_must ssh -t $NFS_USER@$NFS_CLIENT " | ||
log_must ssh -t "$NFS_USER"@"$NFS_CLIENT" " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below, do we need to close quotes around @
?
log_must fio --output-format=${PERF_FIO_FORMAT} \ | ||
--output $outfile $FIO_SCRIPTS/$script | ||
log_must fio --output-format="${PERF_FIO_FORMAT}" \ | ||
--output "$outfile" "$FIO_SCRIPTS"/"$script" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below, wo we need to close/reopen quotes around /
?
done | ||
IFS=$oIFS | ||
|
||
typeset idx=0 | ||
while [[ $idx -lt "${#collect_scripts[@]}" ]]; do | ||
typeset logbase="$(get_perf_output_dir)/$(basename \ | ||
$SUDO_COMMAND)" | ||
"$SUDO_COMMAND")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again quotes inside quotes.
@@ -354,13 +354,13 @@ function populate_perf_filesystems | |||
|
|||
function get_nfilesystems | |||
{ | |||
typeset filesystems=( $TESTFS ) | |||
typeset filesystems=("$TESTFS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be an array initialization. Do we really want to convert empty variable into one element array of empty string?
Motivation and Context
It has been quite some time since shellcheck has been run against the performance test library. Recently there was an issue where $SUDO_COMMAND splitting incorrectly causes the result file paths to be generated incorrectly. We want to fix this issue and get ahead of any other potential issues.
Description
This change goes through and quotes variables where appropriate to avoid issues with incorrect splitting.
How Has This Been Tested?
Ran the perf suite to ensure still working as expected
Types of changes
Checklist:
Signed-off-by
.