From owner-freebsd-arch@FreeBSD.ORG Sat Jun 19 11:31:27 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB08A106566B for ; Sat, 19 Jun 2010 11:31:27 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 736138FC24 for ; Sat, 19 Jun 2010 11:31:27 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 7AC4D1DD748 for ; Sat, 19 Jun 2010 13:31:26 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 6F08C1727C; Sat, 19 Jun 2010 13:31:26 +0200 (CEST) Date: Sat, 19 Jun 2010 13:31:26 +0200 From: Jilles Tjoelker To: freebsd-arch@freebsd.org Message-ID: <20100619113126.GB83874@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Further sh(1) plans X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jun 2010 11:31:27 -0000 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