help-bash
[Top][All Lists]
Advanced

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

Re: Organising conditions


From: Leonid Isaev (ifax)
Subject: Re: Organising conditions
Date: Mon, 2 Aug 2021 15:01:30 +0000
User-agent: Mutt/1.13.4 (2020-02-15)

On Mon, Aug 02, 2021 at 02:46:46PM +0000, hancooper wrote:
> Then doing
> if [[ -d "$dir" && ! $list_raw ]]; then
> or
> if [[ -d "$dir" ]] && [[ ! $list_raw ]]; then
> is simply dependent on preference, rather than functionality?

If you are asking a generic question, then you should consider having more than
two tests. In this case, the former if..then stanza is better because it allows
grouping without subshells. For instance:
-----8<-----
if [[ (-d "$dir" && -z "$new_dir") || (! "$list_raw") ]]; then
...
fi
----->8-----

-- 
Leonid Isaev



reply via email to

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