12
Elendil
1d

I hate bash scripting so much !
What a shit language, its inconsistent af
Its just a pile of hacks upon hacks upon hacks. Theres no rime or reason to bash expansion, or to working with arrays.
Sometimes "$@" is a list, sometimes its not... Because fuck u thats why

So im doing a coding project at work, that has to be in bash for reasons.
It already feels like giving birth, llms are hard-carrying me and im not proud of it

And every time i think im done, and i can close this fucking epic, some issue pops up that necessitates a re-write
3rd one is also a no go apparently

And this all happened because *someone* in another department couldn't be fucked to implement the proper solution for this.
The scope of this piece of shit script keeps growing, because every month they be like

"oh this feature of service xyz ? Nah turns out we cant do that sowwy. But you can implement a workaround in bash right??

If you truly like bash as a language, you're cooked brother. you need to seek professional help :skull:

Comments
  • 4
    I would rebel and write it in python and call that from bash.
  • 3
    Don't write legacy code for starters... I.E. $@

    I for one love bash. My fav language, followed by java and go. But bash is such a cool beast that it's been my #1 for years.
  • 2
    Aaand bash does not have lists. It has arrays though. V4+ bash also has associative arrays [smth like maps]
  • 3
    I strangely like bash but I can't explain why

    it's somehow charming on me when I find all the weirdnesses in it
  • 4
    And all the bashtards are coming out of the wood work...
  • 2
    I hate bash too. I do everything with python since that's installed by default too. @netikras made the whole freaking fine working gpt bot in bash. Crazy actually.
  • 2
    I hate bash too. I do everything with python since that's installed by default too. @netikras made the whole freaking fine working gpt bot in bash. Crazy actually.
  • 2
    Bash is great for automating terminal work. Calling commands in python is a PITA.

    Doing math and working with data structures in bash is way worse though.
  • 1
    @netikras same thing, i just called it a list
  • 2
    @netikras idk like
    Usually when i write bash scripts, i try them to make them POSIX-compliant
    (And as short/simple as possible)

    So there really is no such thing as legacy code for me. Ye it looks ugly as sin, but the fact that they "just work" regardless of shell or os is much more important to me

    You call it "modern better syntax", i call it "GNU coming up with new ways to break my shit" :P

    But, in this specific case, you kinda have a point... Work systems all run the same stuff, it would make sense to standardize on modern bash

    Is there a way to refactor? Some tool that suggests how to refactor code to bash 4.x?
    I use shellcheck religiously but have not seen it so far
  • 0
    @Elendil I don't think there is one. The risk of breaking logic is too high to do it automatically.

    Could it be your machines run on different bash versions? Or bash symlinked to another shell?

    Could you share a repro? You got me curious :)

    I always try to use as few bashisms as possible and stick as close to posix as I can. With a few consistent exceptions :)
  • 0
    I like bash and python.. more readable
Add Comment