DEV Community

Discussion on: Bash Brackets Quick Reference

 
kogans profile image
Info Comment hidden by post author - thread only visible in this permalink

You totally misunderstand what [[ $? ]] actually does. It is actually equivalent to [[ -n $? ]], with -n being the operator for non-empty string test. Since $? always contains an exit status of the last command, it will always be a non empty string, so [[ $? ]] will always return 0 and evaluate to true in if context.

Please read up on how if works in bash and stop screwing up noobs with worthless code.

Thread Thread
 
ferricoxide profile image
Thomas H Jones II

Ok, so, I shortcut on my prior statement. The response was basically, "here's something you can start your Googling with," not, "here's a whole freaking book on the topic." But, congratulations, rage-boy, in your quest to service "noobs" (great to throw that term out there, btw: really shows your head-space and overall level of respect for your community-members), you've extended this thread beyond the scope of a simple Google-starter. And for all of that belaboring, the point still stands that there's many useful, reliable ways to use the $( command )$? construct. Clearly your opinion differs. Clearly you've been badly snakebitten (or otherwise simply have an axe to grind). However, like with any useful tool or construct, just because there are ways that it can fail within a given context, it's still useful when correctly used in the right contexts.

Thread Thread
 
rpalo profile image
Ryan Palo

Hi guys! Just FYI, I’ve muted and moderated both of your comments in this particular thread. Let’s try to keep it positive and helpful for the people who need this info next time. I’d appreciate it if you’d take any further posturing/bickering into dms and out of my comments. Thanks!

Thread Thread
 
ferricoxide profile image
Thomas H Jones II

No worries. After my final reply, I did a "who is this guy" click on his profile noticed that he'd apparently created an account just to piss on the thread (created the day he started thread-crapping and only activity shown on profile is the thread-crapping). So, had no further intent to respond.

Thread Thread
 
kogans profile image
Stanislav Kogan

Yes, I'm new here, but I'm not new. I write a LOT of bash on my job, so when I see these dangerous "recommendations", it makes me cringe.
And you, my friend, should reign in your prideful graphomania and actually TEST your code before you post it.

 
kogans profile image
Stanislav Kogan

You have not demonstrated any useful way of using the $( command )$? construct. Your original one is dangerous and misleading. I'm asking you, please stop screwing over noobs - bash can be very unforgiving and can do a lot of damage when used incorrectly.

Some comments have been hidden by the post's author - find out more