• 𝘋𝘪𝘳𝘬@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    2 months ago

    I gave up Bash scripting. I explicitly do “shell scripting” now, where “shell” is implied to be a POSIX compliant shell of any type.

  • N0x0n@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    2 months ago

    I’m not very acquainted with any programming language so maybe I’m wrong here (or I didn’t get the joke? XD) but bash didn’t change much in the past few years, I even read some scripts more than 10 years still works because the syntax stays the same (or doesn’t change a lot …)

    Compared with the switch from python 2 -> python 3 I read a lot of people pulling their hair off xD

      • eldavi@lemmy.ml
        link
        fedilink
        English
        arrow-up
        4
        ·
        2 months ago

        i forget on the same day; i literally keep a log of everything i did that day so i can look it up. lol

      • N0x0n@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        2 months ago

        Okay XD it’s less funny when you have to explain the joke XD sorry !!

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 months ago

      Here’s an example, I have looked up many times (like just now), which checks whether a string is empty:

      var=""
      if [ -z "$var" ]; then
          echo "empty"
      else
          echo "not empty"
      fi
      

      Why -z? I have no idea. I will also routinely forget the ]; then part. I believe, if you write the then onto the next line, then you don’t need the semicolon. And then someone’s probably gonna tell me to use double-brackets [[ ]] instead, which probably does something.

      Arguably, I never fully learned Bash syntax, but it also is just a stupid if-statement. There shouldn’t be that much complexity in it.

      • balsoft@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        2 months ago

        Why -z? I have no idea.

        From man test (note that [ <expr> ] is just sugar for test <expr>):

               -n STRING
                      the length of STRING is nonzero
        
               -z STRING
                      the length of STRING is zero
        

        So, -z stands for Zero.

        Hope this helps you remember it!

      • Anna@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        1 month ago

        -z means zero length and mostly [[ ]] are used when you want to add multiple conditions. But there are also few test cases which are only in bash so they also need double brackets