LARBS icon indicating copy to clipboard operation
LARBS copied to clipboard

Install dash and make it the default #!/bin/sh symlink.

Open emrakyz opened this issue 1 year ago • 2 comments

Luke Smith Video: Bash is Bloated!

In the linked video Luke has Dash symlinked to /bin/sh.

Extra Information for people:

  • Dash is much faster than Bash especially for the execution.
  • It uses much less resources.
  • It's very minimal.
  • It's POSIX compliant and therefore portable.
  • It's more secure.

We have #!/bin/bash exclusively for the needed scripts so there won't be any problems.

emrakyz avatar Nov 18 '23 22:11 emrakyz

tell me this is possible without breaking the system!!!!

 IFS=:; grep -Irl '#!/bin/sh' /usr/bin |xargs -r checkbashisms

CheesyChocolate avatar Nov 19 '23 09:11 CheesyChocolate

@CheesyChocolate

You don't need to check bashisms. Exclusive Bash scripts have a starting line with #!/bin/bash so it won't break your system.

I have used Dash as a /bin/sh symlink on Arch, Artix, Debian, LFS and now I use it on Gentoo without a problem. So you are good to go.

For example on Gentoo, Portage uses Bash and some Open-RC related scripts have bashisms but it's not related with your /bin/sh symlink. Your /bin/sh symlink is only valid for scripts that start with #!/bin/sh so they won't break scripts starting with #!/bin/zsh or #!/bin/bash lines.

EDIT: checkbashisms is also too old at this point and gives false positives. I use a very customized Gentoo setup and I have always used Dash as a /bin/sh replacement. An example of unrelated bashism reports:

possible bashism in /usr/bin/mailsync line 75 ($_):
					perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')"
possible bashism in /usr/bin/mailsync line 77 ($_):
					perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')"
possible bashism in /usr/bin/gentoo-pipewire-launcher line 39 ('command' with option other than -p):
    if command -v pidwait > /dev/null ; then
possible bashism in /usr/bin/gentoo-pipewire-launcher line 41 ('command' with option other than -p):
    elif command -v pwait > /dev/null ; then
possible bashism in /usr/bin/zdiff line 159 (type):
                        if type mktemp >/dev/null 2>&1; then

emrakyz avatar Nov 19 '23 10:11 emrakyz