help-bash
[Top][All Lists]
Advanced

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

Re: Organising conditions


From: hancooper
Subject: Re: Organising conditions
Date: Mon, 02 Aug 2021 15:20:44 +0000



Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, August 2, 2021 2:56 PM, Greg Wooledge <greg@wooledge.org> wrote:

> On Mon, Aug 02, 2021 at 02:43:36PM +0000, hancooper wrote:
>
> > Do (-d "$dir") and (! $list_raw) also fork a subshell?
>
> Outside of the [[ ]] command, yes.
>
> Inside of the [[ ]] command, no.

I will remember that.

> > Is it fine to fork subshells when using conditions as I do? I do not know 
> > much about
> > whether forking of subshells in bash is good, bad, or whatever.
>
> It's bad. It's a massive performance hit for no reason.

That would be bad.  I do get occasional problems with speed, making additional 
latency
unsuitable to actually use.


> 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?
>
> Yes. Also, the one with parentheses INSIDE the [[ ]] command is fine
> as well.
>
> Just don't put parentheses OUTSIDE.

Much thanks for explaining things to me.



reply via email to

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