tests-always-included / mo

Mustache templates in pure bash
Other
563 stars 67 forks source link

"Unbound variable" in latest version #67

Closed robertcoltheart closed 1 year ago

robertcoltheart commented 1 year ago

Running in centos using 3.0.0, I get the following error:

/usr/local/bin/mo: line 208: moFiles[@]: unbound variable

Command used:

echo "test" | /usr/local/bin/mo

fidian commented 1 year ago

I am unable to reproduce this error. Would you send me the output from set +o and shopt -p so I can set up my system the same as yours and possibly reproduce the problem?

robertcoltheart commented 1 year ago

See below:

set +o

set +o allexport
set -o braceexpand
set -o emacs
set +o errexit
set +o errtrace
set +o functrace
set -o hashall
set -o histexpand
set -o history
set +o ignoreeof
set -o interactive-comments
set +o keyword
set -o monitor
set +o noclobber
set +o noexec
set +o noglob
set +o nolog
set +o notify
set +o nounset
set +o onecmd
set +o physical
set +o pipefail
set +o posix
set +o privileged
set +o verbose
set +o vi
set +o xtrace

shopt -p

shopt -u autocd
shopt -u cdable_vars
shopt -u cdspell
shopt -u checkhash
shopt -u checkjobs
shopt -s checkwinsize
shopt -s cmdhist
shopt -u compat31
shopt -u compat32
shopt -u compat40
shopt -u compat41
shopt -u direxpand
shopt -u dirspell
shopt -u dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extdebug
shopt -s extglob
shopt -s extquote
shopt -u failglob
shopt -s force_fignore
shopt -u globstar
shopt -u gnu_errfmt
shopt -u histappend
shopt -u histreedit
shopt -u histverify
shopt -u hostcomplete
shopt -u huponexit
shopt -s interactive_comments
shopt -u lastpipe
shopt -u lithist
shopt -s login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nocasematch
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u syslog_history
shopt -u xpg_echo
fidian commented 1 year ago

Thanks for the extra information. I still can't replicate the issue. What version of bash do you use? What version of centos? I will set up a virtual machine and attempt to replicate the problem.

It's weird that the error message says unbound variable because line 113 assigns an empty array to it.

robertcoltheart commented 1 year ago

Here's a bit more for you. Its on EC2 using an Amazon2 AMI:

bash --version
GNU bash, version 4.2.46(2)-release (x86_64-koji-linux-gnu)
cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
robertcoltheart commented 1 year ago

I've gone back to the latest 2.x release for now, and that seems to work fine.

fidian commented 1 year ago

Thanks for working with me to solve the issue, I sincerely appreciate the help.

The bug has been fixed and I pushed out 3.0.1 with the change.

fidian commented 1 year ago

Unfortunately, I didn't bother running the tests after the last change, so the simple case of echo "works" | ./mo worked, but not everything. 3.0.2 works better for Bash 4.