Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jun 2010 13:31:26 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        freebsd-arch@freebsd.org
Subject:   Further sh(1) plans
Message-ID:  <20100619113126.GB83874@stack.nl>

next in thread | raw e-mail | index | archive | help
It appears useful to say some more about my plans with sh(1).

My main focus with sh(1) is to improve it as a scripting shell. This
includes changes to improve compatibility, small additions to the
language (usually from POSIX) and features to help script writers.

However, sh(1) also has some interactive facilities, such as command
line editing and history provided by libedit. Various people had asked
for a small addition to these: filename completion. I was a little
hesistant about this, as sh is not and will not be zsh. But every once
in a while sh usage happens, so when a related patch came in I asked for
a port of NetBSD's filename completion with some additions, and got it.

The result is not as featureful as completion in shells like bash and
zsh, but I think it is still useful, better than nothing. Trying to
avoid nasty surprises, completed filenames are quoted (this is not in
NetBSD). Things like command completion and completing only directories
for cd are not present, but I think this is only an annoyance, not a
nasty surprise (note, for example, that bash's completion does not
understand logical/physical directories correctly, so completing ../
often gives wrong results if the directory was reached through a
symlink).

For embedded systems, it may be best to disable libedit entirely in the
end product (we don't currently have a knob for this). If you need to
log in to such a system, the additions will likely be useful, as there
may not be any other shell on the system. The completion code is fairly
small compared to the rest of libedit.

Some other sh(1) ideas:

* import dash arithmetic code (smaller code, proper short-circuit
  evaluation)
* printf builtin (because it is seeing more use such as by recent
  versions of autoconf and I do not want to encourage people to write
  fragile and non-portable echo commands by making printf much slower
  than echo; embedded folks might replace the printf binary with a
  script like /usr/bin/alias)
* kill builtin (%job specifiers, search order, reliability)
* fail <&FD if FD is not open
* clean up error handling for getcwd in cd -P
* fix ${x#"}"} so it trims a closing brace
* add $'quoting with C-style escape sequences' (under discussion in the
  Austin Group)
* do word splitting on p q r in ${x+p q r}
* cause syntax error for :; fi outside if
* make search order for builtins more compliant (special builtins cannot
  be overridden except by aliases, PATH does not affect certain other
  builtins such as fg)
* remove let and exp builtins (useless)

Most of these ideas have patches in my patch queue. Some of the patches
in the queue may never be committed.

http://www.stack.nl/~jilles/cgi-bin/hgwebdir.cgi/sh-patches/file/tip

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100619113126.GB83874>