On Ubuntu, I have set alias sh='rlwrap --complete-filenames sh' to get readline keybindings and filename completion when using the dash shell (on my computer, sh is /usr/bin/sh, which is a symbolic link to /usr/bin/dash). However, rlwrap does not seem to handle SIGTSTP correctly. Consider the following shell session:

In bash:

[email protected]:~$ alias sh='rlwrap --complete-filenames sh'
[email protected]:~$ sh  # Run dash.

In dash:

$ sleep 100  # Right after this, I press Ctrl-Z to send SIGTSTP.
[1]+  Stopped                 rlwrap --complete-filenames sh
[email protected]:~$  # What!? Why do I get a bash prompt!?

When I press Ctrlz, dash is stopped instead of sleep. How do I make SIGTSTP stop the foreground process running in dash, instead of stopping dash itself? What is the correct way to use rlwrap with dash?

I know that as an alternative to rlwrap, I could compile dash with libedit (./configure --with-libedit) to get readline functionality (using dash -E), but unfortunately that does not seem to support filename completion.

  • 1
    Why? dash is a good shell for running scripts, if you don't need newer features like arrays. It makes a lousy, minimalist interactive shell. Just use bash, ksh, or zsh for interactive shells and for scripts where you don't care about speed and/or need arrays, and dash where shell script performance is paramount (but if decent performance is required, you should probably be writing in awk or perl or a compiled language like C instead).
    – cas
    Dec 26, 2021 at 10:35
  • "sh" should be a giveaway. For most shells, when a shell is linked to a symbolic link /bin/sh, it makes the shell behave as a POSIX-compliant minimal shell for scripting. Not to mention that dash is also the same otherwise. If the OP wants a minimal interactive shell, he can try mksh. Dec 28, 2021 at 8:57

1 Answer 1


How do I make SIGTSTP stop the foreground process running in dash, instead of stopping dash itself?

This is not what you want. rlwrap cannot know what is in the dash job table and direct its anesthetic darts to one of dashs subprocesses accordingly.

The solution can be much simpler, however: just forward the CTRL+Z keypress to dash (by binding it to rlwrap-direct-keypress in your .inputrc).

With current rlwrap this doesn't work, however: rlwrap mirrors all dashs terminal settings (including VSUSP, the suspend character) so rlwrap will never even see the keypress.

This is on my TODO list (see https://github.com/hanslub42/rlwrap/issues/111)

Hans (rlwrap maintainer)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .