Escape $ in getopts

This commit is contained in:
Maniack Crudelis 2019-03-16 16:05:32 +01:00 committed by GitHub
parent e24890c2f2
commit 23d7a0005d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -152,6 +152,8 @@ ynh_handle_getopts_args () {
fi
# Escape double quote to prevent any interpretation during the eval
all_args[$i]="${all_args[$i]//\"/\\\"}"
# Escape $ as well to prevent the string following it to be seen as a variable.
all_args[$i]="${all_args[$i]//$/\\\$}"
eval ${option_var}+=\"${all_args[$i]}\"
shift_value=$(( shift_value + 1 ))
@ -193,6 +195,8 @@ ynh_handle_getopts_args () {
# Escape double quote to prevent any interpretation during the eval
arguments[$i]="${arguments[$i]//\"/\\\"}"
# Escape $ as well to prevent the string following it to be seen as a variable.
all_args[$i]="${all_args[$i]//$/\\\$}"
# Store each value given as argument in the corresponding variable
# The values will be stored in the same order than $args_array