On Fri, Dec 22, 2017 at 1:39 PM, Kevin Layer <la...@known.net> wrote:
> The bug happens to me on > GNU bash, version 4.1.2(2)-release (x86_64-redhat-linux-gnu) > and > GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.4.0) > > The script is attached, but the function in question is this: > > function debug1 { > [ "$debug" ] && echo "$(date "+%Y-%m-%d %H:%M:%S"): $@" > } > > This is expected behavior. When "$debug" is empty, the [ command exits 1. That means the && isn't run, and the whole function returns with the status of the last run command, which is still 1 at this point. http://mywiki.wooledge.org/BashFAQ/105