I was curious about this so I downloaded a source code tarball from the upstream DASH downloads and extracted the source files. I checked for a README file which should provide information on the program and its build options, but there wasn’t any, so I ran ./configure --help
and its output includes:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-libedit Compile with libedit support
So, it looks like the libedit library is used to provide line editing capabilities but this is not the default when building the source. I also found this response to a mailing list message on set -o vi not working:
I think this requires dash to be built with libedit support to work.
I checked what libraries were linked to the dash
executable on my Ubuntu server and noted libedit
wasn’t included:
$ ldd /bin/dash
linux-vdso.so.1 => (0x00007fffcfbd6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f013a0b7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f013a475000)
I imagine that when the Debian package maintainers are building the dash
package, they omit this optional configuration as they would not want sh
to have external dependencies on other libraries. They could probably link the library statically but the main reason for using dash
as sh
is to keep the shell as small and fast as possible so that the start-up scripts run quickly.
Edit: I just searched for “libedit dash” and the top result was a very similar question on this site which was well answered by muru.
Building Dash with line editing support
For those who might be interested, these are are steps required to build from source.
Download the most recent source tarball:
wget http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.9.tar.gz
wget http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.9.tar.gz.sha256sum
Verify the authenticity of the tarball:
sha256sum -c <( awk '/dash/{ print $1 " " $3}' dash-0.5.9.tar.gz.sha256sum )
gpg --verify --auto-key-retrieve dash-0.5.9.tar.gz.sha256sum
Extract the source files and change into the source directory:
tar -xf dash-0.5.9.tar.gz
cd dash-0.5.9
Run ./configure --with-libedit
to create the Make files. However, this will fail quietly unless the development version of the libedit
library is installed. It would be better if the configure script complained more verbosely as it wasn’t obvious that it was failing to find the required files.
sudo apt-get install libedit-dev
./configure --with-libedit
Build the program and (optionally) install it into /usr/local/bin
:
make
sudo make install
dash
does not come with any Readline (or similar) library support leading to this behavior. – heemayl Sep 19 '16 at 03:03ksh
also doesn't have readline support, yet vi mode works there. If that's the case, then whyman dash
doesn't reflect this ? – Sergiy Kolodyazhnyy Sep 19 '16 at 03:12