Bash-like scripting in shells is prevalent in operating systems but I don’t understand why, when it doesn’t have the syntax to make programming easy like other languages. What features does bash have that make it so suitable for shells? Why even new operating systems like Redox OS choose a very similar syntax over a completely different programming language?

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

    why are you stuck with bash? just write a shebang and then your interpreter in the first line of your script.

    i can use bash, python, lua and al kinds of stuff…

    i don’t understand the question. if you mean, why does my shell only accept bash syntax, if i set my shell to bash, idk. use another shell?

    ‘sh’ is kind of the smallest common thing that’s available everywhere. so when you got to script something that needs to run somewhere not under your control, you use ‘sh’. and that’s kind of it works. you’ll find something, that’s been around for some time, otherwise it won’t have spread everywhere. and now you can’t replace it in newer products, because there is so much stuff using it.

    • clb92@kbin.social
      link
      fedilink
      arrow-up
      11
      arrow-down
      1
      ·
      1 year ago

      I’m gonna get crucified for saying this, but… I write a lot of my scripts in PHP. It’s just a language that I’m very familiar with.

      • db2@lemmy.one
        link
        fedilink
        arrow-up
        11
        ·
        1 year ago

        This isn’t reddit, if that tool does the jobs effectively then great.

      • maegul (he/they)@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        crucified?! You’re awesome mate!

        Plus, on the fediverse, PHP’s kinda cool again (I think) … or at least should be.

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

        ( my oppinion: i personally don’t like php and js for being too complicated. they are very easy to begin with, which is a good thing. but too difficult to master. there are soo many weird things going on, so many edge cases to remember, and all the pitfalls that are there to help the beginner but require a professional to pay close attention. i like something strict, maybe with type safety and a compiler that yells at you if you’re forgetting something or trying to do something stupid. not silently convert it. )

        Other than that: Whatever floats your boat… I don’t think it’s wrong to use something like php. i have used it and still use it from time to time. heck, i’ve even used lua where people start counting with ‘1’. sometimes it is the correct tool. sometimes it’s more important to get a job done, than having it done in a certain way. and of course people like to work with something that they’re familiar with. you’re probably better off and faster this way.

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

        I’ve used Js for scripts, especially when JSON is involved.

        My logic is to use whichever language is best for the job out of those I’m familiar with, and can be understood by people who might read it. Then I forget logic and try to use lisps wherever possible.