[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Organising conditions
From: |
Greg Wooledge |
Subject: |
Re: Organising conditions |
Date: |
Mon, 2 Aug 2021 10:23:32 -0400 |
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.
- Organising conditions, hancooper, 2021/08/02
- Re: Organising conditions,
Greg Wooledge <=
- Re: Organising conditions, hancooper, 2021/08/02
- Re: Organising conditions, hancooper, 2021/08/02
- Re: Organising conditions, Leonid Isaev (ifax), 2021/08/02
- Re: Organising conditions, hancooper, 2021/08/02
- Re: Organising conditions, Greg Wooledge, 2021/08/02
- Re: Organising conditions, hancooper, 2021/08/02
- Re: Organising conditions, Greg Wooledge, 2021/08/02
- Re: Organising conditions, hancooper, 2021/08/02
- Re: Organising conditions, Greg Wooledge, 2021/08/02
- Re: Organising conditions, Leonid Isaev (ifax), 2021/08/02