FreeBSD sh on Linux?

Jilles Tjoelker jilles at stack.nl
Thu Mar 10 20:18:22 UTC 2016


On Wed, Mar 09, 2016 at 08:27:05PM +0700, C Bergström wrote:
> On Wed, Mar 9, 2016 at 8:13 PM, Jason Hellenthal
> <jhellenthal at dataix.net> wrote:

> > On Mar 9, 2016, at 02:06, Brendan Sechter <sgeos at hotmail.com> wrote:

> > > Is there any reason why FreeBSD sh can't be used on Linux?  dash
> > > is not a suitable login shell and bash is GNU.

You'd need to do some work to make it compile. There is a package called
libbsd which should be helpful.

The filename completion in FreeBSD sh also uses a FreeBSD-local patch to
libedit. This will be problematic if you want to maintain a package in a
distribution.

> > It's just the ash(1) shell with a few modifications that's a little
> > more standard than most. Shouldn't be any reason why it can't

There are quite a few bugfixes, features and performance improvements
that are in FreeBSD sh and not in most other ash variants, such as UTF-8
support, $'...' to embed control characters and Unicode more easily,
simple command substitutions without fork() and vfork() use. Therefore,
I think the original question is reasonable, if the request is for a
scripting shell (including for system() and make).

> /* not meaning to be a troll */

> If you're going down this route - there's also ksh93 from solaris,
> which may be easy to extract (or maybe has done so already.. not sure)
> in my experience it's that nice balance between bare minimum sh and
> bash.

ksh93 is in ports.

I think it is more rather than less featureful than bash, though. It has
programming features such as lexically-scoped variables and user-defined
data types. Interactive features are a bit more limited. It is quite
fast as well.

Downsides are that it can be buggy, development has slowed down,
commonly available versions are quite incompatible with other shells and
the programming features are still not nearly as good as more modern
non-shell programming languages such as Python.

> There's also fish and zsh if you want tons of features..

I think those are better choices for interactive use.

There is also mksh which is in between FreeBSD sh and bash in features.
I don't like it for interactive use because it does not support editing
a very long logical line such as a for loop on multiple physical lines,
but you may not mind that.

-- 
Jilles Tjoelker


More information about the freebsd-hackers mailing list