0

I'm working on building my own Linux distribution based off Debian. I am curious if it is possible to completely remove dash and replace it with as shell like fish or elvish. I am aware that you would need to make several changes but I am curious if it is possible and the process you would need to take to go about it.

Alice
  • 1
  • I don't know what elvish is, but fish AFAIK doesn't even try to support POSIX syntax, so it's not viable as a dash replacement. – muru May 25 '22 at 02:43
  • @muru Possibly not a drop-in replacement, but as the user seems willing to make "several changes"... – Kusalananda May 25 '22 at 06:14
  • To give you the most helpful answer, it is relevant to know what could be your goal you want to achieve. – Philippos May 25 '22 at 06:53
  • @Kusalananda even then, I don't think it can be meaningfully be said to be "based off Debian", since the package maintainer scripts probably implicitly trust that sh understands POSIX syntax. They'd have to build their own packages, and the average third-parties that support Debian-based distros by providing deb files won't work either. At that point, the only relation to Debian is that they're using apt and dpkg. – muru May 25 '22 at 06:54
  • @muru This is most definitely true. – Kusalananda May 25 '22 at 06:57
  • 1
    Even parts of dpkg rely on /bin/sh being a POSIX-style shell (its cron job, dpkg-maintscript-helper, and dpkg-realpath), as do parts of apt (its cron job and systemd timer, its kernel integration package handling, and apt-key). – Stephen Kitt May 25 '22 at 07:15

1 Answers1

6

There's nothing stopping you installing additional shells, but if we're talking about a general purpose Unix-like system such as Debian, you'll need to make sure your system has a /bin/sh shell that supports the POSIX sh syntax¹. That shell is used for instance by the system("some sh code") of many programming languages and to interpret scripts without shebangs (and of course all those with a #! /bin/sh - shebang).

That doesn't have to be dash, that could be bash, ksh88², mksh, bosh, posh, even zsh³ whose sh mode is likely good enough. fish, elvish, csh, tcsh, rc, es are examples of shells with completely different syntax from that of POSIX sh, so can't be used as sh there.

Among those, dash is probably the best choice as it's leaner, faster and safer than most of the others, where all you need it to do is interpret POSIX sh code. It's also the shell used by Debian and most of its derivatives so has one of the largest user bases as a sh interpreter which means problems if any are generally spotted and fixed quickly.

At least, the situation is better in Debian-like systems. On some other GNU-based systems, /bin/sh has to be bash (the GNU implementation of sh) as some of the system scripts use some of the non-standard extensions of that shell. Debian has put some significant effort into removing all those so-called bashisms so bash could be replaced with a leaner/faster shell such as dash for its /bin/sh.

In any case, it's always possible to have a system working perfectly without any shell, or without any command or even filesystem at all, just by implementing what the system is meant to do in the kernel directly, so, strictly speaking, the answer to this kind of question will always be yes as long as you're ready to build your own system from scratch.


¹ strictly speaking, for Debian, that has to be shells compliant to the Debian policy which is a superset of POSIX. Among the additional things sh has to support there is the local keyword/builtin to get local scope for variables in functions.

² That's the shell (a subset thereof) on which the POSIX sh specification is based, however it was never released as FLOSS, so you'll have a hard time finding a build of it for GNU/Linux.

³ while yash is another POSIX compliant shell, I would avoid it because of its general inability to handle non-text data. busybox ash is also mostly POSIX compliant, but beware that depending on how busybox was built, it may call busybox applets instead of the corresponding system commands and some of them are not POSIX compliant so would break scripts that expect the full POSIX feature set. ksh93 is mostly POSIX compliant, but doesn't support the local required by the Debian policy. See also List of shells that support `local` keyword for defining local variables