Closed siliconjesus closed 4 years ago
bash 3.2 do not have the -v varname
operator: to check if a variable is set. so I changed it to a bash [34].x compatible check.
That should fix the first part
-bash: [: -v: unary operator expected
Check it please
For the
-bash: syntax error near unexpected token `('
See #8. I recommend to close this and stick to that issue to fix that part
For both instances, I'm using a 4.x version of bash.
GNU bash, version 4.1.2(2)-release (x86_64-redhat-linux-gnu) Copyright (C) 2009 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.
$ bash --version GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin17.3.0) Copyright (C) 2016 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.
-v
conditional was included on bash 4.2 http://wiki.bash-hackers.org/scripting/bashchanges#conditional_expressions_and_test_command
As said that should be fixed on master
@siliconjesus for me is ok to open 2 issues for two different use cases, mix here CentOS and Mac only makes it hard to provide support.
I have brew too so I guess I can upgrade bash too. I suggest to keep this issue for CentOS and comment on #8 for MacOSX
As #8 is fixed and unary operator
was already fixed on master I will close this issue.
NOTE: I don't have access to a bash 4.1, bash 4.2 so my suspiction that bash 3 was nongreedy on extglob
and bash 4 was greedy, could be really bash >4.2 being nongreedy and <=4.2 being greedy.
script is now checking BASH_VERSINFO
with has access to major and minor version.
If you are still interested in this issue and master still do not fix it, please try again and report the remaining fails, so we can tweak the inflexion point for this greedy behaviour.
Tried this on CentOS 6.9 (bash 4.1.2(2)) and MacOSX with bash installed (4.4.19(1)) via brew.
Sourced the script, then ran it against a config file I'm trying to parse with a format similar to the following:
I get the following error:
I attempted to run the example in the script directory as well.