From b453adb88c2c8331c8568b44c34716460bceb115 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 15 Apr 2021 22:28:08 +0900 Subject: [PATCH] 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. --- include/opt.sh | 7 +++++++ 1 file changed, 7 insertions(+) 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 +} -- 2.47.3