]> git.corax.cc Git - toolbox/commitdiff
include/opt: Make opt_get_argv() print arguments line-by-line
authorMatthias Kruk <m@m10k.eu>
Sun, 27 Feb 2022 08:59:27 +0000 (17:59 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 27 Feb 2022 08:59:27 +0000 (17:59 +0900)
Because `opt_get_argv()` prints the entire command line in one line,
callers cannot reliably parse individual arguments from the output.

This commit modifies `opt_get_argv()` to print the arguments line-
by-line.

include/opt.sh

index 18c4c59f6a40252339ff7da43d60226d02544fc1..7c96c7bb1989c1a952f7f8508b0032f7997fa61e 100644 (file)
@@ -239,6 +239,9 @@ opt_get() {
 }
 
 opt_get_argv() {
-       echo "${__opt_argv[@]}"
+       if ! array_to_lines "${__opt_argv[@]}"; then
+               return 1
+       fi
+
        return 0
 }