mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Remove escape character in getopts
This commit is contained in:
parent
3a8d312ed2
commit
0ad8daa6ae
1 changed files with 4 additions and 1 deletions
|
@ -77,7 +77,7 @@ ynh_handle_getopts_args () {
|
||||||
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
||||||
do
|
do
|
||||||
# Escape options' values starting with -. Otherwise the - will be considered as another option.
|
# Escape options' values starting with -. Otherwise the - will be considered as another option.
|
||||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]}-/--${args_array[$option_flag]}\\-}"
|
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]}-/--${args_array[$option_flag]}\\TOBEREMOVED\\-}"
|
||||||
# And replace long option (value of the option_flag) by the short option, the option_flag itself
|
# And replace long option (value of the option_flag) by the short option, the option_flag itself
|
||||||
# (e.g. for [u]=user, --user will be -u)
|
# (e.g. for [u]=user, --user will be -u)
|
||||||
# Replace long option with =
|
# Replace long option with =
|
||||||
|
@ -155,6 +155,9 @@ ynh_handle_getopts_args () {
|
||||||
eval ${option_var}+="\;"
|
eval ${option_var}+="\;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Remove the \ that escape - at beginning of values.
|
||||||
|
all_args[i]="${all_args[i]//\\TOBEREMOVED\\/}"
|
||||||
|
|
||||||
# For the record.
|
# For the record.
|
||||||
# We're using eval here to get the content of the variable stored itself as simple text in $option_var...
|
# We're using eval here to get the content of the variable stored itself as simple text in $option_var...
|
||||||
# Other ways to get that content would be to use either ${!option_var} or declare -g ${option_var}
|
# Other ways to get that content would be to use either ${!option_var} or declare -g ${option_var}
|
||||||
|
|
Loading…
Add table
Reference in a new issue