Date: Sun, 22 Aug 2010 13:04:00 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r211621 - head/bin/sh Message-ID: <201008221304.o7MD40lP004588@svn.freebsd.org>
index | next in thread | raw e-mail
Author: jilles Date: Sun Aug 22 13:04:00 2010 New Revision: 211621 URL: http://svn.freebsd.org/changeset/base/211621 Log: sh(1): Add a brief summary of arithmetic expressions. Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 ============================================================================== --- head/bin/sh/sh.1 Sun Aug 22 12:03:31 2010 (r211620) +++ head/bin/sh/sh.1 Sun Aug 22 13:04:00 2010 (r211621) @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd June 29, 2010 +.Dd August 22, 2010 .Dt SH 1 .Os .Sh NAME @@ -1230,7 +1230,7 @@ Quote Removal. The .Ql $ character is used to introduce parameter expansion, command -substitution, or arithmetic evaluation. +substitution, or arithmetic expansion. .Ss Tilde Expansion (substituting a user's home directory) A word beginning with an unquoted tilde character .Pq Ql ~ @@ -1463,10 +1463,41 @@ The shell expands all tokens in the .Ar expression for parameter expansion, -command substitution, and quote removal. +command substitution, +arithmetic expansion +and quote removal. +.Pp +The allowed expressions are a subset of C expressions, +summarized below. +.Bl -tag -width "Variables" -offset indent +.It Values +All values are of type +.Ft intmax_t . +.It Constants +Decimal, octal (starting with +.Li 0 ) +and hexadecimal (starting with +.Li 0x ) +integer constants. +.It Variables +Shell variables can be read and written +and contain integer constants. +.It Unary operators +.Li "! ~ + -" +.It Binary operators +.Li "* / % + - << >> < <= > >= == != & ^ | && ||" +.It Assignment operators +.Li "= += -= *= /= %= <<= >>= &= ^= |=" +.It Short-circuit evaluation +The +.Li && +and +.Li || +operators always evaluate both sides. +This is a bug. +.El .Pp -Next, the shell treats this as an arithmetic expression and -substitutes the value of the expression. +The result of the expression is substituted in decimal. .Ss White Space Splitting (Field Splitting) After parameter expansion, command substitution, and arithmetic expansion the shell scans the results ofhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008221304.o7MD40lP004588>
