• shrek_is_love@lemmy.ml
      link
      fedilink
      arrow-up
      20
      ·
      1 day ago

      I know this is a meme and not GitHub, but I thought some people might like to learn that if you do please shutdown && thanks it won’t say you’re welcome if the shutdown failed

      • juipeltje@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 day ago

        Wait, isn’t it the other way around? I thought ; only executed the next command if the previous one succeeded, and && executed the next command regardless of exit status.

        • Fmstrat@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          22 hours ago

          Partly right in bash:

          set -e; echo 1; echo 2;
          

          is the same as

          echo 1 && echo 2
          

          So if you see the -e in a script, it’s to keep the function clean.

          • juipeltje@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            1 day ago

            Ah yes you’re right, had to look it up to see for myself. It’s weird because i remember specifically changing some of my &&s for ; instead because i wanted it to not continue if exit wasn’t zero, but i must’ve misread it at the time. Time to change it back i guess lol.

            • JackbyDev@programming.dev
              link
              fedilink
              English
              arrow-up
              3
              ·
              1 day ago

              It makes more sense if you think of semicolons like other programming languages like Java and C use it.

              foo();
              bar();
              

              But those languages allow foo(); bar(); as well. Then && works like a normal short circuited expression (with side effects).

    • Arthur Besse@lemmy.ml
      link
      fedilink
      English
      arrow-up
      11
      ·
      edit-2
      2 days ago

      alias thanks="You are most welcomed"

      you need to use the echo command if you want to echo something:

      alias thanks="echo 'You are most welcomed'"

      (the inner single-quotes are not strictly required in this case, but recommended nonetheless)