From fa34368592109e8feb088ff7a129489e92d00a7a Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Thu, 9 Jan 2014 10:34:47 -0500 Subject: [PATCH] Fixed a bug where cmdarg_argv is not populated without -- --- README.md | 5 +++++ cmdarg.sh | 3 +++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 0e1536f..151c3f4 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,11 @@ Similarly, cmdarg understands '--' which means "stop processing arguments, the r ... Cmdarg would parse -x and --longopt as expected, and then ${cmdarg_argv[0]} would hold "--some-thing-with-dashes", for your program to do with what it will. +getopt vs getopts +================= + +cmdarg does not use getopt or getopts for option parsing. Its parser is written in 100% pure bash, and is self contained in cmdarg_parse. It will run the same way anywhere you have bash4. + Tests ===== diff --git a/cmdarg.sh b/cmdarg.sh index dd08685..facb41c 100644 --- a/cmdarg.sh +++ b/cmdarg.sh @@ -243,6 +243,9 @@ function cmdarg_parse elif [[ "${fullopt:0:1}" == "-" ]] && [[ ${#fullopt} -eq 2 ]]; then opt=${fullopt:1} longopt=${CMDARG[$opt]} + elif [[ "${fullopt:0:1}" != "-" ]]; then + cmdarg_argv+=("$fullopt") + continue else echo "Malformed argument: ${fullopt}" >&2 echo "While parsing: $@" >&2