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?

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    ·
    16 hours ago

    I have fish set as the default command to run when my terminal emulator starts, but my system-wide default shell is bash and I always throw a #!/bin/sh or #!/bin/bash shebang at the top of my scripts either way.

    With that setup, I hardly notice fish’s syntax differences. Are you using it like that, too?

    • Victor@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      13 hours ago

      Scripting in fish is so wonderful though.

      Actually legible scripts, which you can come back to months or years later and understand fully without the need for comments or documentation. Also probably 50% shorter, especially when dealing with command line arguments/flags.

    • pantherina@feddit.orgOP
      link
      fedilink
      arrow-up
      1
      ·
      13 hours 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
        4
        ·
        11 hours 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! ?