• Mwa@thelemmy.club
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    i am using ZSH cause Fish is not POSIX compliant,which made it annoying to run scripts without rewriting them.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 days ago

      When is this a problem? What scripts don’t use a shebang and/or why does using sh call fish instead of bash or dash?

      I have a mild dislike of fish because a few substitutions are different enough that my muscle memory isn’t there. (But I also haven’t put in serious effort to learn them.)

        • JackbyDev@programming.dev
          link
          fedilink
          English
          arrow-up
          0
          ·
          9 days ago

          Have you run into a specific problem or is this just a hypothetical you’re worried about. I see this a lot but haven’t ever actually run into it being a concern. If you run a script with #!/bin/sh from a Fish shell, it won’t use Fish, it will use whatever you have sh pointing to. (Which shouldn’t be Fish, it’s usually bash or dash.)

          • Mwa@thelemmy.club
            link
            fedilink
            English
            arrow-up
            0
            ·
            8 days ago

            I ran into issues on fish,i don’t remember what they are but I think it’s no shebang

      • Mwa@thelemmy.club
        link
        fedilink
        English
        arrow-up
        0
        ·
        10 days ago

        how about if its not in a sh file,its common for scripts to use sh or bash instead. but am just gonna stick to ZSH anyways

        • trevor (any/all) @lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          0
          ·
          10 days ago

          The file extension doesn’t matter much on Linux. If you’ve got a shebang at the top, the shell you’re running from will invoke the correct shell according to the shebang.

          In some situations, you may want to use something like bash <your-script>, but that would only be when you’ve got a script that doesn’t have a shebang, but not having one is bad practice and you really should be using them. Fish isn’t the only non-POSIX shell you’re going to encounter on a Linux system. Python, Perl, and probably some others will be there, and using a shebang ensures no shenanigans. So whether or not you use Fish, you should always use shebangs.

        • Hawke@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          10 days ago

          Linux doesn’t generally use extensions to decide what shell to use, so it doesn’t matter if it’s an sh file or not.

          If it uses bash of course you can substitute #!/bin/bash

          And of course you can use whatever shell you want, just saying that POSIX-compliance is not really relevant since the script can specify what shell it needs.