From: Matthias Kruk Date: Thu, 15 Apr 2021 13:28:08 +0000 (+0900) Subject: include/opt: Remember arguments passed to opt_parse() X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=b453adb88c2c8331c8568b44c34716460bceb115;p=toolbox include/opt: Remember arguments passed to opt_parse() To allow the user to distinguish running instances of a script, it is necessary to present the arguments that an instance was started with. The most logical place to remember such information is inside the opt module. Therefore, this commit adds the opt_get_argv() function, which allows the caller to retrieve the arguments that were passed to the opt_parse() function. --- diff --git a/include/opt.sh b/include/opt.sh index 7af5be3..d04e3e8 100644 --- a/include/opt.sh +++ b/include/opt.sh @@ -108,6 +108,8 @@ opt_parse() { local opt local i + declare -argx __opt_argv=("$@") + for (( i = 1; i <= $#; i++ )); do local param local long @@ -169,3 +171,8 @@ opt_get() { echo "${__opt_value[$long]}" return 0 } + +opt_get_argv() { + echo "${__opt_argv[@]}" + return 0 +}