Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

/bin/sh vi-mode command line editing pathname expansion

6 views
Skip to first unread message

Nathan Weeks

unread,
Apr 2, 2010, 10:22:56 AM4/2/10
to freebsd-...@freebsd.org
The following vi-mode command line editing features seem to be
missing from FreeBSD 8.0's /bin/sh.

=
Display the possible shell word expansions (see wordexp )
of the bigword at the current command line position...
\
Perform pathname expansion (see Pathname Expansion )
on the current bigword, up to the largest set of characters
that can be matched uniquely...
*
Perform pathname expansion on the current bigword and
insert all expansions into the command to replace the current
bigword, with each expansion separated by a single <space>...

Full descriptions are here:

http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html

This would be handy to have out-of-the-box so one doesn't have
to install bash or ksh to have a POSIX shell that can do this kind
of pathname expansion in an interactive shell.

--
Nathan Weeks

Jilles Tjoelker

unread,
Apr 3, 2010, 12:02:04 PM4/3/10
to Nathan Weeks, freebsd-...@freebsd.org
On Fri, Apr 02, 2010 at 08:22:56AM -0600, Nathan Weeks wrote:
> The following vi-mode command line editing features seem to be
> missing from FreeBSD 8.0's /bin/sh.

> =
> Display the possible shell word expansions (see wordexp )
> of the bigword at the current command line position...
> \
> Perform pathname expansion (see Pathname Expansion )
> on the current bigword, up to the largest set of characters
> that can be matched uniquely...
> *
> Perform pathname expansion on the current bigword and
> insert all expansions into the command to replace the current
> bigword, with each expansion separated by a single <space>...

> Full descriptions are here:

> http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html

"bigword" is not good: it disallows file name completion with spaces
(unless we implement ksh-like $'quoting' and put in $'\040' for a
space, which is ugly).

> This would be handy to have out-of-the-box so one doesn't have
> to install bash or ksh to have a POSIX shell that can do this kind
> of pathname expansion in an interactive shell.

NetBSD has file name completion in sh/libedit (optionally with <Tab> as
people expect) but I think it is still a bit too simplistic: it does not
quote spaces and the like. Because not doing this quoting is highly
surprising in a negative way and other shells I've tried (bash, zsh,
ksh93, mksh) do it, I think it is a requirement.

If stefanf@ (de facto libedit maintainer) ports over the NetBSD code and
someone takes care of the quoting issue, I would not be opposed to it.

A more general question is how far we should go with this kind of
features. Our /bin/sh is not bash or zsh and probably should not be.
Unfortunately, this means that people who want a good interactive
Bourne-style shell have to resort to ports/packages and install bash,
zsh, mksh or possibly ksh93. I don't think non-embedded operating
systems based on FreeBSD should default to /bin/sh as a shell for users.

--
Jilles Tjoelker

Nathan Weeks

unread,
Apr 8, 2010, 1:07:00 PM4/8/10
to Jilles Tjoelker, freebsd-...@freebsd.org

That all sounds reasonable. If this were implemented, there would be less
incentive to for me to install bash or ksh in every jail.

--
Nathan Weeks

0 new messages