2 ms·
I somehow already read that in the past but here, in this condensed form, it now actually makes sense. I think you just cured me of my bash fear. Thanks for tha
by cassepipe 4y ago
I somehow already read that in the past but here, in this condensed form, it now actually makes sense. I think you just cured me of my bash fear. Thanks for that explanation.
I'll make sure to either use test or [[ and never [ again so that I remember the difference. And I am currently reading man test
- pas 4y agoI think using test would be the best, even if it's awkward, but [[ is a Bashism (so not POSIX shell compatible), and [ is jut an alias for test and requires that dumb closing bracket, and you are already execve()-ing a separate program for comparison, you are already depending on the exit code, so why not make it explicit by using test. (I continue to use [[ and never look back, just forward, trying to picture the shining city on a conveniently sloped hill, where people live without fear in their hearts, where they have compile time checking for their scripts, and the compiler gently pushes them toward sane error handling. Not too much, but definitely not too little. Something like Rust's Result type.)