Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dash-separated option referenced in ARG_TYPE_GROUP_SET generates invalid variable in bash #25

Closed
pbabinca opened this issue Aug 21, 2017 · 1 comment
Assignees

Comments

@pbabinca
Copy link

Following minimal reproducer:

$ cat invalid_group_var.m4                            
#!/bin/bash

# m4_ignore(
echo "This is just a script template, not the script (yet) - pass it to 'argbash' to fix this." >&2
exit 11  #)Created by argbash-init v2.4.1a
# ARG_HELP([<The general help message of my script>])
# ARG_OPTIONAL_REPEATED([long-option])
# ARG_TYPE_GROUP_SET([MYGROUP], [GROUP-TYPE], [long-option], [ foo,bar ])
# ARGBASH_GO

# [ <-- needed because of Argbash

echo "Value of --foo: ${_arg_long_option[@]}"

# ] <-- needed because of Argbash
$ argbash -o invalid_group_var.sh invalid_group_var.m4

Ran with bash:

$ bash invalid_group_var.sh --long-option foo --long-option bar
invalid_group_var.sh: line 88: _arg_long_option__long-option_SUFFIX=foo: command not found
Value of --foo: foo bar

produces error ^.

Relevant line is 78:

$ nl invalid_group_var.sh | tail -n 10
    77	_arg_long_option="$(MYGROUP "$_arg_long_option" "long-option")" || exit 1
    78	_arg_long_option__long-option_SUFFIX="$(MYGROUP "$_arg_long_option" "long-option" idx)"
       
    79	### END OF CODE GENERATED BY Argbash (sortof) ### ])
    80	# [ <-- needed because of Argbash
       
       
    81	echo "Value of --foo: ${_arg_long_option[@]}"
       
    82	# ] <-- needed because of Argbash

I'm running the code with latest updates of Red Hat Enterprise Linux 7.4:

$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ m4 --version
m4 (GNU M4) 1.4.16
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Rene' Seindal.
@matejak matejak self-assigned this Aug 25, 2017
@matejak
Copy link
Owner

matejak commented Aug 25, 2017

Good catch, thank you for taking time to report it with the nice example! I will fix it shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants