1

I am looking for a *NIX shell where most of the basic functionality - ls, cat, etc. - is done internally and not called via exec to outside programs. busybox does something with symlinked binary names calling back to itself, but it still calls exec instead of just calling the programs internally. Is there a fully self-contained shell like this somewhere? I can't seem to Google up anything.

Thank you in advance!

4
  • 1
    Why are you trying to avoid fork/exec? Jan 30, 2018 at 18:09
  • Looking to experiment with full internal for embedded, trying to reduce as much overhead as possible. A call to an internal ls() function is a lot leaner than an exec() call. Thanks
    – Brendan
    Jan 30, 2018 at 18:32
  • Something like u-root.tk or busybox?
    – gsiems
    Jan 30, 2018 at 19:04
  • FWIW: u-root has a github page: github.com/u-root/u-root/blob/master/roadmap.md
    – gsiems
    Jan 30, 2018 at 19:07

3 Answers 3

4

Busybox can be configured to run its internal implementations of some of its executables ("applets") directly if the following options are set:

  • FEATURE_PREFER_APPLETS=y ("exec prefers applets")
  • FEATURE_SH_STANDALONE=y ("Standalone shell")
  • FEATURE_SH_NOFORK=y ("Run 'nofork' applets directly")

These options are all disabled by default, so you will need to build busybox from source to enable them.

Note that many applets do not support NOFORK.

3
  • I stuck the enable for this in the .config file and recompiled, but when running busybox i still get calls to exec/fork/etc. Is there some command i need to do other than busybox ash to enter the nofork/noexec applets shell?
    – Brendan
    Jan 30, 2018 at 21:51
  • @Brendan Updated my answer -- there's several compile flags involved
    – user15323
    Jan 30, 2018 at 23:00
  • Got it - modified the .config and the 'make menuconfig' (curses interface), it seems most calls now are just calling within the binary. I just need to make some small changes to the source and I'm good. I appreciate the help!
    – Brendan
    Jan 31, 2018 at 21:44
1

You could use sash "stand-alone shell".

From the description of the Debian package:

sash serves as an interactive substitute for /bin/sh, for use when /bin/sh is unusable. It's statically linked, and includes many standard utilities as builtins (type "help" at the prompt for a reference list). If you've installed sash before rendering your system unbootable, and you have some knowledge of how your system is supposed to work, you might be able to repair your system using init=/bin/sash at the boot prompt.

1
  • Thank you, another good option. Might be easier to modify than busybox too.
    – Brendan
    Jan 31, 2018 at 21:44
1

You may have a look into bash-static, a statically linked version of bash.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.