Describe the bug
Found a bug with optional arguments and final array.
To Reproduce
Define a docopt like this one in a shell script:
#!/usr/bin/env bash
##? Install a package
##?
##? Usage:
##? $0 [--pkgmgr <package_manager>] <packages_names>...
eval "$(docpars -h "$(grep "^##?" "$0" | cut -c 5-)" : "$@")"
echo "pkgmgr: $pkgmgr"
echo "package_manager: $package_manager"
echo "packages: ${package_names[*]}"
echo
Call the script with arguments:
--pkgmgr cargo docpars deno bashdoc
Show output:
pkgmgr: true
package_manager: cargo
packages: docpars deno bashdoc
Fail 1
All went well, but if you call with arguments:
Will show you:
pkgmgr: false
package_manager: docpars
packages: deno bashdoc
The docpars value is in package_manager and not in the final array.
Fail 2
And finally if you call the script with arguments:
It will output:
pkgmgr: true
package_manager:
packages: cargo
cargo is in packages_names instead of package_manager.
Expected behavior
Case fail 1
pkgmgr: false
package_manager:
packages: docpars deno bashdoc
Case fail 2
pkgmgr: true
package_manager: cargo
packages:
Screenshots

Versions:
- OS: macos 11.4 Big Sur
- Shell Version [replace this text with the output of
sh --version]
> $SHELL --version
zsh 5.8 (x86_64-apple-darwin20.0)
Additional context
The script is dot package add of my Dotly fork, see it here:
Describe the bug
Found a bug with optional arguments and final array.
To Reproduce
Define a docopt like this one in a shell script:
Call the script with arguments:
Show output:
pkgmgr: true package_manager: cargo packages: docpars deno bashdocFail 1
All went well, but if you call with arguments:
Will show you:
The
docparsvalue is inpackage_managerand not in the final array.Fail 2
And finally if you call the script with arguments:
It will output:
cargois inpackages_namesinstead ofpackage_manager.Expected behavior
Case fail 1
pkgmgr: false package_manager: packages: docpars deno bashdocCase fail 2
Screenshots

Versions:
sh --version]Additional context
The script is
dot package addof my Dotly fork, see it here: