• pinchcramp@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    121
    arrow-down
    1
    ·
    edit-2
    1 year ago

    Bash script. Not necessarily hard to understand but very unintuitive in my opinion. I’ve written so much bash script over the years and still have to look up how to do simple things like iterate over associative arrays or do basic string manipulation. Maybe it’s just a me problem though 🤷

    • guy@lemmy.world
      link
      fedilink
      arrow-up
      42
      arrow-down
      2
      ·
      1 year ago

      I have to write powershell scripts and bash scripts at work. I hear people saying bash is great, powershell is bad, all the time in public, but honestly I feel like these people have barely actually written powershell. It’s a bit wordy, but it feels much more intuitive to me, much more akin to regular programming languages.

      • NewDark@unilem.org
        link
        fedilink
        arrow-up
        24
        arrow-down
        2
        ·
        1 year ago

        It’s newer and Microsoft based. Easy way to get a bunch of people on the hate train for those reasons alone.

      • shalafi@lemmy.world
        link
        fedilink
        arrow-up
        11
        arrow-down
        1
        ·
        1 year ago

        PS was built from the ground up to be intuitive. There are some interesting videos from the MS devs talking about the design process.

      • zygo_histo_morpheus@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        I can see how PS might be better for writing actual programs in but the wordiness really gets in the way when youre just trying to write something on the command line so it feels poorly optimized for cli usage. Bash is very poorly optimized for writing programs otoh.

      • miversen33@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        1 year ago

        My main issue with PS is that it is JavaScripty. And by that I mean, it makes tons of assumptions on what I “mean” by my command. And it’s usually right and thus I don’t see any issues. But when those assumptions are wrong, I have to do all kinds of parameter fuckery to make it be what I “expect”.

        None of that is true is bash. It doesn’t make many assumptions at all (at least none that I’ve come across). Things act the same when I’m using bash in a script vs the cli vs over an ssh connection vs within a subshell, etc.

        And ya the whole “it’s pretty verbose” is irritating too (though that could also be a counter argument against bash relying on magic variables and abusing the shit out of symbols).

        I don’t hate PS but I don’t enjoy spending time in it. I don’t hate bash but it hurts me less when I use it

      • 30p87@feddit.de
        link
        fedilink
        arrow-up
        5
        arrow-down
        2
        ·
        1 year ago

        It’s not necessarily PS itself, I bet it would be fine on a Linux machine with a typical Linux terminal. It’s just that I cannot stand the rest of Windows, especially the CLI part, especially cmd: Awful to no tab complete support, no command history across cmd restarts, if tab complete works its only for files and even sucks there because of the ignore case design and completing a full name instead of to the next clear step (eg. “tes” for a dir containing “test.exe” and “test.mp4” will complete to “test.exe” instead of “test.”). Additionally, I associate PS with Windows and tasks on it. Most things I want to run on Linux only I write in C/C++ (depending on the task itself ofc). If I want compatibility with Linux and Windows I use python. To install that script to a usable state it’s literally a single command on Linux, if the method of transferring the script (probably a git repo) supports saving the executable permission bit: sudo cp script.py /usr/local/bin/patchjar.py. Even if you want an own directory with your own path, that’s no problem: Just cp a .sh file to /etc/profile.d/ that appends to the path. And removing it is as easy as deleting that file. On Windows? Chocolatey has a ~100 line script just for that purpose, backs up the path just in case and even explicitly states uninstall it can break your whole system? Why? Because Windows uses a single global PATH variable for everything. You need to edit the registry, extract your path with loops, remove it and write it back. And that’s a pattern being repeated through the whole OS. You want to move a window on the screen or start something on another monitor? Well fuck you. On Linux? assign [app_id=TuxKart] workspace gaming. For an OS claiming to be integrated with everything in itself that seems like pretty damn dumb and frustrating to a dev.

        • lud@lemm.ee
          link
          fedilink
          arrow-up
          6
          ·
          1 year ago

          You shouldn’t really use CMD at all anymore. It’s pretty shit. Just use PowerShell (I prefer the newer version 7)

        • Tathas@programming.dev
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          You’re talking about PowerShell but then complaining about cmd. Are you unaware that PowerShell is its own cli?

      • Schmeckinger@feddit.de
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 year ago

        I have done a lot of powershell scripting and found some very annoying edge cases, they all have solutions, but feels unnecessary. I once had a issue, where I had a dynamic array of strings and if thst array was only 1 long it would give you the first character instead of the first string. I don’t know exactly what made that happen, but I think it had something to do with functions or classes.

    • Lupec@lemm.ee
      link
      fedilink
      arrow-up
      13
      arrow-down
      1
      ·
      1 year ago

      Yup, same. I’ve been a developer for years and used to code way before that and to this day I can’t write any non trivial bash script without looking up half a dozen of things lol, glad I’m not alone.
      I’ve recently come across nushell, and it’s everything I’ve ever wanted when it comes to shell scripting. It’s not POSIX compliant so you can’t just run it anywhere but it helps keep my sanity in personal projects and whatnot. See also, elvish, xonsh.

      • nous@programming.dev
        link
        fedilink
        English
        arrow-up
        13
        arrow-down
        1
        ·
        1 year ago

        Concurrency is not easy if you need the output and exit status of the commands. Fire and forget concurrency/parallelism is easy in any language. It is when you need to sync state up that it becomes hard.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      1 year ago

      Yeah, anything to do with iterative over strings. Basically anything that involves IFS is unintuitive.

    • atheken@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      My running joke, after four different friends told me they were using ChatGPT to help them with it, is that the language is so hard to learn that we invented an entirely new class of AI to help.

      It’s a joke, of course, but it does have some “surprising” syntax, since some stuff is whitespace sensitive, and there are subtle differences between () and [] and [[ ]], for example. All of that’s due to the long history of shell behavior, so I don’t necessarily blame bash.

    • UFO@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      I don’t think it’s just a you problem :)

      I’ve been curious to try fish or zsh to hopefully run into less weirdness.

      • pinchcramp@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        1 year ago

        I don’t think it’s just a you problem :)

        I didn’t think so. I guess Reddit has conditioned me to not state my opinion without a disclaimer, lest someone wants to start arguing :D

        Btw. I don’t think you’ll find ZSH more intuitive to program. While it is an awesome interactive shell, the scripting part is Bash taken to the extreme.