help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] confused by command substitution...


From: Greg Wooledge
Subject: Re: [Help-bash] confused by command substitution...
Date: Mon, 11 Feb 2019 11:50:26 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Mon, Feb 11, 2019 at 11:45:58AM -0500, Alfred M. Szmidt wrote:
>    > I'm not understanding the difference here, or why the last example
>    > works.  Anyone got a good explanation?
>    > 
>    > $ if "$(echo x)"; then echo foo; fi
>    > bash: x: command not found
>    > $ if "$(echo x > /dev/null)"; then echo foo; fi
>    > bash: : command not found
>    > $ if $(echo x); then echo foo; fi
>    > bash: x: command not found
>    > $ if $(echo x > /dev/null); then echo foo; fi
>    > foo
> 
>    They're all 100% wrong.  
>    
> Clearly they aren't.  They are also syntatically valid according to
> POSIX grammar rules from what I can see.

A syntactically parseable command can still be wrong, if it does not
do what it's supposed to do.

What is "x"?  Why are you echoing it?  Why are you capturing the result of
that echo and executing it as a second command?  What is the significance
of the exit status of "x" which is apparently the secondary command you
wish to execute?

Why are you not simply executing x directly?

What are you trying to do?

Why are you brushing me off and telling me to calm down instead of
presenting a question that people can actually help you with?



reply via email to

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