[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] confused by command substitution...
From: |
David Niklas |
Subject: |
Re: [Help-bash] confused by command substitution... |
Date: |
Mon, 11 Feb 2019 21:15:08 -0500 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On Mon, 11 Feb 2019 11:50:26 -0500
Greg Wooledge <address@hidden> wrote:
> On Sat, Feb 09, 2019 at 06:01:53AM -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. If one of them happens not to throw a syntax
> error, that's just bash's way of lulling newbies into complacency so
> that their scripts blow up LATER instead of IMMEDIATELY. Obviously a
> script that APPEARS to work has a better chance of going into production
> in a broken state. This maximizes the chances of chaos and destruction.
> Bash craves these things. The suffering of fools is its lifeblood.
ROFL
On Mon, 11 Feb 2019 11:50:26 -0500
Greg Wooledge <address@hidden> wrote:
> On Mon, Feb 11, 2019 at 11:45:58AM -0500, Alfred M. Szmidt wrote:
> <snip>
> >
> > 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?
We are like bash. We send you senseless problems to drive you to the edge
of your sanity, then we send a halt-and-catch-fire instruction your CPU,
and then you.. are.. ours! Mwha! Ha! Ha! Ha!
Hope my message is equally funny,
David
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEL2N7+xWmVOJDQxWGm3XCrhg2YP8FAlxiLCwACgkQm3XCrhg2
YP+ykhAA07DUSVyLw9LjgCUPf7SLO/AvDagX+pfKN216qhaBnZTQz/0KCCkGm7KU
9ZoZEk3lv9/8IIW1Q+7IX+9KPXnnCs6Bn4zm3+QtggQ+NH2TKgMJZ7Zye3co+dmW
LC6OwH7crxg6p5yEQIJ4CmnEjYPmo8nX9XPYxpE8JL6XYmIG2aEZcdvbHIh9AEkt
xin/sAfSwrDK/At9dy7OlQsXkIetw9DG0oCltl0aGa5oBqd2Sv8KFmQ9+uzEhoIF
Rabbcne2B8Trpe7fe/WVlyP2z+Ny+/NffvYp0FQHvHhJJIcOF5L4hNe494kMheM+
k/VBNw3dS8m8gIDXe1vDgVYwiOTUYjVgg993ITyyC7i3Sj9otmwhF1d1AC8gDoNC
ngd2mt39E3Lk1kc7xdcwg3oHBArntn7WQBPmT+KTzFlX1SdvNCs7QVkBHvD6146J
iWfUliPCnhinLWg4w8ZT9ayVLUH9H9CjMyHZBk2tBh9xqT2v8sagaL8xTHyqK1kT
tpHV+qflX2B7D1Gmc6aQPtnQ0nyFcUP1G0EaX39BJSl7rIO67O+20UrumC27Z9fK
dGNopNUNUVHUbpSRf8uPG+TSIIAy6/lvPrNmzmSxpaJw/MC3wZ56Un75xn0aOsi2
trleW/fAdPwNIhNp6P2dYbY+H4pWVhAM8wLQqul8m0xWZMEDCY8=
=4dbc
-----END PGP SIGNATURE-----