From owner-svn-src-head@FreeBSD.ORG Sun Feb 22 21:32:58 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EE44FA62; Sun, 22 Feb 2015 21:32:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C043B98A; Sun, 22 Feb 2015 21:32:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1MLWw6d073621; Sun, 22 Feb 2015 21:32:58 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1MLWwSe073620; Sun, 22 Feb 2015 21:32:58 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201502222132.t1MLWwSe073620@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 22 Feb 2015 21:32:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279188 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Feb 2015 21:32:59 -0000 Author: jilles Date: Sun Feb 22 21:32:57 2015 New Revision: 279188 URL: https://svnweb.freebsd.org/changeset/base/279188 Log: sh: Add details about importing the environment and initializing OPTIND. Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 ============================================================================== --- head/bin/sh/sh.1 Sun Feb 22 20:52:29 2015 (r279187) +++ head/bin/sh/sh.1 Sun Feb 22 21:32:57 2015 (r279188) @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd November 14, 2014 +.Dd February 22, 2015 .Dt SH 1 .Os .Sh NAME @@ -1196,17 +1196,18 @@ command is implemented as a special buil .Ss Variables and Parameters The shell maintains a set of parameters. A parameter -denoted by a name is called a variable. +denoted by a name +(consisting solely +of alphabetics, numerics, and underscores, +and starting with an alphabetic or an underscore) +is called a variable. When starting up, -the shell turns all the environment variables into shell +the shell turns all environment variables with valid names into shell variables. New variables can be set using the form .Pp .D1 Ar name Ns = Ns Ar value .Pp -Variables set by the user must have a name consisting solely -of alphabetics, numerics, and underscores. -The first letter of a variable name must not be numeric. A parameter can also be denoted by a number or a special character as explained below. .Pp @@ -1369,6 +1370,10 @@ This variable overrides the .Va MAIL setting. There is a maximum of 10 mailboxes that can be monitored at once. +.It Va OPTIND +The index of the next argument to be processed by +.Ic getopts . +This is initialized to 1 at startup. .It Va PATH The default search path for executables. See the @@ -2297,6 +2302,8 @@ If an invalid option is encountered, is set to .Ql \&? . It returns a false value (1) when it encounters the end of the options. +A new set of arguments may be parsed by assigning +.Li OPTIND=1 . .It Ic hash Oo Fl rv Oc Op Ar command ... The shell maintains a hash table which remembers the locations of commands. With no arguments whatsoever, the @@ -2771,7 +2778,7 @@ This is inherited by children of the she editing modes. .El .Pp -Additionally, all environment variables are turned into shell variables +Additionally, environment variables are turned into shell variables at startup, which may affect the shell as described under .Sx Special Variables .