-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Shorter if syntax #112
Comments
I do not understand what you are trying to tell. |
Thank you very much.
…On Thu, Dec 9, 2021, 4:04 PM Michael Phillips ***@***.***> wrote:
I do not understand what you are trying to tell.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV7BMB2TZLLR2FZW4FR3FHTUQDHPZANCNFSM4WTEZRYA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I am so confused by this. |
|
I'm sure you found a solution by now, but just in-case you didn't: You have two syntax errors, because you're missing the The Why? Because what the first example actually means is that the 2nd command will execute if the 1st one succeeds, or the 3rd command will execute if the 1st command fails. However, if the 1st command succeeds and the 2nd command also happens to fail, then all three commands wind up being executed regardless. Understanding this is very important, as you can wind up doing some pretty stupid stuff otherwise. Furthermore, the exit statuses are not contained, unlike with an |
"Shorter if syntax" should be removed to stop spreading miss-information. More context can be found here: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3 |
Agreed, it's misleading and incorrect. I see what the author meant, but it's important to be accurate when it comes to complicated matters like programming, IMO. Logical operators can be used similar to an |
[[ 1 == 1 ]] && { command exit 1 } || { this command will exec }
how to avoid???
The text was updated successfully, but these errors were encountered: