bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple function causes BASH to exit when -e in effect


From: DJ Mills
Subject: Re: simple function causes BASH to exit when -e in effect
Date: Fri, 22 Dec 2017 13:50:55 -0500

On Fri, Dec 22, 2017 at 1:39 PM, Kevin Layer <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]