Closed jcooley closed 3 years ago
Hi @jcooley
Sorry for the delay, I'm a bit away from keyboard. :sun_with_face:
Could you attach the script that fires up that bug? And how you run it.
Could you give me the docopts version please, too.
Also please note that the docopt syntax must in include the progname
before the argument: prog arg1 arg2 etc...
# Usage: command1 arg1 arg2
Does the progname
is missing here?
Regards, Sylvain.
Hi Sylvain,
Just back from a break too. I'm using the latest docopts using ./get_docopts.sh
I can reproduce it with the debian 9 docker image
$ docker run --rm -it -v /src/docopts:/docopts debian:9 /bin/bash
# cd /docopts/
# apt update
# apt install wget
# ./get_docopts.sh
and when I run the quick_example.sh I see
panic: no fields found in usage (perhaps a spacing error).
goroutine 1 [running]:
main.main()
/tmp/docopts_v0.6.3-rc2.5349/docopts.go:458 +0xfc7
root@979777acbdfc:/docopts/examples#
but I can fix it by moving the command up to the Usage: line
-# Usage:
-# quick_example.sh tcp <host> <port> [--timeout=<seconds>]
+# Usage: quick_example.sh tcp <host> <port> [--timeout=<seconds>]
If I can provide more detail let me know.
Thanks, James
Hi @jcooley,
Thanks reporting this issue.
I ran your commands on Linux xubuntu 20.04, and I did reproduce the error.
It is the same error as https://github.com/docopt/docopts/issues/47#issuecomment-669899049. It's related to a change I made in the docopts.sh
helper using a gawk
regexp feature to extract the help string. awk
command is not always gawk
it's some time mawk
which has lower feature on regexp syntax.
I commited a fix:
https://github.com/docopt/docopts/commit/c21151315bea2852ef3250c70a52352c9cd0d6eb
I reran the following commands:
cd /tmp
# a fresh new master copy
git clone git@github.com:docopt/docopts.git
docker run --rm -it -v /tmp/docopts:/docopts debian:9 /bin/bash
# inside the container
apt update -y
# file and wget are required in order to run ./get_docopts.sh
apt install -y vim git tree file wget
cd /docopts/
./get_docopts.sh
cd ./examples/
Now is seems OK.
./quick_example.sh
error:
Usage:
quick_example.sh tcp <host> <port> [--timeout=<seconds>]
quick_example.sh serial <port> [--baud=9600] [--timeout=<seconds>]
quick_example.sh -h | --help | --version
Unit testing:
cd ../tests/
git clone https://github.com/bats-core/bats-core.git
./bats-core/install.sh /usr/local
running tests
bats ./docopts.bats
✓ docopt_get_help_string
✓ docopt_get_help_string with Options (this test may fail if bats fix their issue #224)
✓ docopt_get_help_string with with 2 Usage:
✓ docopt_get_values
✓ docopt_get_eval_array
✓ docopt_get_raw_value
✓ docopt_print_ARGS
✓ docopt_print_ARGS -G
✓ docopt_get_version_string from $0
✓ bash strict mode docopt_print_ARGS
10 tests, 0 failures
It should be ok. I close this issue, reopen if some problem persists.
Thanks @Sylvain303, I was back on the server during the week and the fix worked great.
Only the line containing the "Usage:" identifier is parsed on Debian GNU/Linux 9 (stretch)
It works fine on 4.4.20 (Ubuntu 18.04.4).
I was also seeing the following on 4.4.12
but I fixed this by pulling the first line of usage back up to the e.g.
and not
Either will work on 4.4.20. I am using
The workaround is to delete all usage lines before the one that is required at the time.