You are not logged in.

#1 2021-11-07 10:51:02

duyinthee
Member
Registered: 2015-06-14
Posts: 242
Website

should I dash while my shell is bash?

I read about dash at https://wiki.archlinux.org/title/Dash
It says 4 times faster than bash, great. So I installed it and tested scripts using it explicitly like

#!/usr/bin/dash

It works and great. Very smooth.

But I still wonder should I use dash while my shell is bash?

I don't want to relink /bin/sh to dash because I'm not very advanced so I couldn't fix if something is messed up.

And is there any benefit of using dash scripting my things like dwm status, battery monitoring loop, checking reminders, etc... while my shell is bash because it is like running another program unnecessarily?
Or can it be bad technically?

Offline

#2 2021-11-07 12:56:06

lmn
Member
Registered: 2021-05-09
Posts: 88
Website

Re: should I dash while my shell is bash?

duyinthee wrote:

But I still wonder should I use dash while my shell is bash?

That is a question only you can answer for yourself and depends on waht you expect from your shell.
You can change your default shell to be dash and see for yourself.

duyinthee wrote:

I don't want to relink /bin/sh to dash ...

Good while on paper all scripts using the #!/bin/sh shebang should only use POSIX feature set in practice this is often misused and should be reported as an upstream bug.

duyinthee wrote:

...running another program unnecessarily?

Executed scripts invoke their specified command in a new process, so as far as I know there is no difference between using another shell inside a running shell session.

duyinthee wrote:

Or can it be bad technically?

No but dash does come with a limited feature set compared to more fleshed out shells (bash/zsh). So if you need more performant scripts go for it, you can always change them back.
Also there are some good resources for shell scripting online and in this forum (look in the programming section) as a lot of performance can be gained by using the shell and associated tools correctly.

Offline

#3 2021-11-07 13:46:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: should I dash while my shell is bash?

duyinthee wrote:

... because it is like running another program unnecessarily?

And which program is that exactly?  Yes, running a dash script runs dash.  But if it were a bash script, it'd run bash.  One or the other is "necessary".  So the question is which is more efficient.

FYI, busybox's ash will beat dash on most metrics of speed and low resource use - especially if you enable all the builtins (sed, grep, awk ...) so these are never called as external programs.  I use ash for everything and have re-linked /bin/sh to ash.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB