On Mon, Aug 02, 2021 at 01:52:00PM +0000, hancooper via wrote:
> I am using some conditions and would like some assessments on the following.
> For instance, are
> they all valid?
> if [[ -d "$dir" && ! $list_raw ]]; then
> tmpfile=$oldfile
> fi
> if [[ -d "$dir" ]] && [[ ! $list_raw ]]; then
> tmpfile=$oldfile
> fi
> if [[ (-d "$dir") && (! $list_raw) ]]; then
> tmpfile=$oldfile
> fi
Those three are fine. Pick whichever one you like.
> if ([[ -d "$dir" && ! $list_raw ]]); then
> tmpfile=$oldfile
> fi
This one is not advised. The parentheses create a subshell, which forks
a child shell process. This is simply unnecessary. It's not even adding
to readability.