I am writing POSIX shell scripts quite often, mostly for speed and portability. Though, that might not even be needed, as bash might have gotten a speed increase compared to dash, ash and whatnot.

Here are some tests I plan to run to see if the speed difference is still the case

As my normal user shell I use fish since quite some time. I enjoy

  • a simple PS1 that shows the git branch, git status, truncated path where I am
  • autocompletion based on history
  • autosuggestions from -h or --help even if the tool has no autocompletions in other shells
  • abbr instead or alias is quite cool to not forget the actual commands. But I can live without

I dont use more features really. I have a couple of fish functions, and fish might just be a better bash with easier syntax. But bash is the standard, so I never use them anyways.

I wouldnt want to switch to zsh because it is weird permissively licensed. But if it is faster or better than bash, maybe?

I also like that fish is completely rewritten in rust. There is rusty-bash aka. sushi shell, anyone use that? Is is compatible with modules?

Are these extensions just scripts that you run on startup of the shell?

  • pantherina@feddit.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    3 days ago

    I think so. If I do ./script.sh I get fish errors, same with . script.sh

    Only sh script.sh works, which is dash inside of fish

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      5
      ·
      3 days ago

      That is definitely not right. That sounds like you don’t have a shebang or it isn’t defined correctly. The shebang has to be the very first thing in the script, with no whitespace before it. It gets read out by the kernel, which very dumbly checks the first few bytes.

      And well, such a shebang should also work for Python or the like. If you copy the first script in this link into a file script.py, then run chmod +x script.py and finally run ./script.py, does that print Hello, World! ?

      • pantherina@feddit.orgOP
        link
        fedilink
        arrow-up
        1
        ·
        2 hours ago

        Well my shebang is #!/bin/sh which might break because I am on NixOS XD

        So fish might fallback to using fish

        • Ephera@lemmy.ml
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          60 minutes ago

          I’m on NixOS for my personal laptop, too. I just tried it and well, #!/bin/bash apparently does not work, but #!/bin/sh does.

          The file /bin/sh does also exist as a symlink for me:

          > ls -l /bin/sh
          lrwxrwxrwx 1 root root 73 14. Dez 19:50 /bin/sh -> /nix/store/35yc81pz0q5yba14lxhn5r3jx5yg6c3l-bash-interactive-5.3p3/bin/sh*
          

          Does that point into the bash package for you, too?


          Edit: And for #!/bin/bash, the output was:

          > ./test
          exec: Failed to execute process './test': The file specified the interpreter '/bin/bash', which is not an executable command.