From owner-freebsd-arch@FreeBSD.ORG Tue Dec 13 22:00:22 2011 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 388791065673 for ; Tue, 13 Dec 2011 22:00:22 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id BB4AA8FC08 for ; Tue, 13 Dec 2011 22:00:21 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 1FF3C359331 for ; Tue, 13 Dec 2011 23:00:21 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 06ED128468; Tue, 13 Dec 2011 23:00:21 +0100 (CET) Date: Tue, 13 Dec 2011 23:00:20 +0100 From: Jilles Tjoelker To: freebsd-arch@freebsd.org Message-ID: <20111213220020.GA42285@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Some sh(1) plans for 10.0 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: Tue, 13 Dec 2011 22:00:22 -0000 Here are some changes that may happen to sh(1) in 10.0. * Report output errors in builtins (error message and exit status 2). For example: echo >&-. PR bin/158206. * Special expansion for assignments in export/readonly/local. This expands assignments in a command like export a=~ b=$1 as if the "export" were not there (tilde expansion after = and :, no pathname generation, no word splitting). This feature has been available in ksh/bash/zsh for a long time and has been proposed and defined for a new version of POSIX at http://austingroupbugs.net/view.php?id=351 Users sometimes get confused by this not working and if POSIX plans to add it, why not add it here? * 'time' keyword, allowing timing of pipelines and compound commands. This works such that if any options are specified, it will fall back to /usr/bin/time. The proposed changes to POSIX are fairly extensive including changes to the ! keyword which will break some of our scripts and a TIMEFORMAT variable. A somewhat stripped version may be useful. Note that a shell-based version cannot and will not support SIGINFO. This is also the case with the versions in tcsh, bash and zsh. http://austingroupbugs.net/view.php?id=267 * Conditional command [[ ... ]] much like ksh. This is being discussed in the Austin Group at this time. I don't really like the duplication with [ ... ] and case, considering that they work well in the POSIX spec and our implementation. Some reasons to add it anyway are that it is slightly easier to use and cleaner in syntax, that < and > can use locale-specific ordering (strcoll) (but when are strings compared for greater-than in a shell script?) and that a regex match could be added. A slightly older proposal is at https://docs.google.com/document/d/1Gd9r0f0rmmUIZlBnO4NyhTz2q-_1PHHGVCHAglFbJoY/edit * vfork support, with an environment variable to opt out. * Executing commands in subshell environments without forking in more situations (saving and restoring state manually instead). * Here document expansion without a fork. A simple implementation would make expansion side effects persistent and errors fatal while a more complicated implementation could avoid that. A fork is still needed if the here document cannot be written into a pipe without blocking. (This could be avoided with ugly SIGIO magic but the case seems too rare to bother.) * If execve() fails even though the file exists and is executable, and it should not be run using /bin/sh ([ENOEXEC] and text file), give a clearer error message. Example: #! interpreter does not exist. Some rework could make all execve() errors detected in the child process of this kind. -- Jilles Tjoelker