‹ BackHN Continuity

Thread

Telling a Computer to Do Things

91 points · 37 comments · vismit2000

  1. necovek · · focus · HN ↗
    I was pretty close in guessing what they believe was "wrong" (or really, superfluous) with their initial shell script example.

    I'd even drop the "if" from their footnote version, and go with simply

      npm install || (echo "boom" && exit)
    
    (Not exactly equivalent because there won't be an "exit" if echo fails, but it's my preferred instict over ";") Also, "(" starts a subshell, if we are being pedantic.
    1. Sharlin · · focus · HN ↗
      I wonder if there’s some obscure syntax for "do this if the preceding command fails and propagate its exit code". For just returning some error you can of course have something like `die("boom")` (though not as a builtin?) but sometimes it’s useful to know the exact code.
      1. [deleted] · · focus · HN ↗

        [deleted]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.