Closed gdevenyi closed 1 year ago
Actually, here's an even smaller reproducer:
#!/bin/bash
#
# This is a rather minimal example Argbash potential
# Example taken from http://argbash.readthedocs.io/en/stable/example.html
#
# ARG_OPTIONAL_SINGLE([option], [o], [optional argument help msg])
# ARG_OPTIONAL_BOOLEAN([print], , [boolean optional argument help msg])
# ARG_POSITIONAL_SINGLE([positional-arg], [positional argument help msg], )
# ARG_HELP([The general script's help msg])
# ARGBASH_GO
# [ <-- needed because of Argbash
local color_debug="\\x1b[35m"
# ] <-- needed because of Argbash
Looks like the parser doesn't like bash colour codes.
https://argbash.readthedocs.io/en/stable/index.html#limitations
The square brackets in your script have to match (i.e. every opening square bracket [ has to be followed at some point by a closing square bracket ]).
There is a workaround — if you need constructs s.a. red=$'\e[0;91m', you can put the matching square bracket behind a comment, i.e. red=$'\e[0;91m' # match square bracket: ].
So you can simply add a comment as such
#!/bin/bash
#
# This is a rather minimal example Argbash potential
# Example taken from http://argbash.readthedocs.io/en/stable/example.html
#
# ARG_OPTIONAL_SINGLE([option], [o], [optional argument help msg])
# ARG_OPTIONAL_BOOLEAN([print], , [boolean optional argument help msg])
# ARG_POSITIONAL_SINGLE([positional-arg], [positional argument help msg], )
# ARG_HELP([The general script's help msg])
# ARGBASH_GO
# [ <-- needed because of Argbash
local color_debug="\\x1b[35m" #]
# ] <-- needed because of Argbash
Thanks for the reference. It's nice and all, but it doesn't solve the issue that I didn't know to look there when the parser crashed :+1:
This is a technical limitation of the underlying technology. I know that this is a pain, and sorry for that, it is at least on the first page of the documentation under section Limitations.
I was integrating some of the pretty printing functions from https://github.com/kvz/bash3boilerplate/blob/master/main.sh in my project when I found that argbash could no longer re-parse the template and generate a new set of parsing code.
I have narrowed it down to this reproducer using the simple argbash template example surrounding it:
Which crashes the parser