corrected typos, more user remarks

This commit is contained in:
tille 2005-09-05 13:01:08 +00:00
parent 3b5078a8cb
commit 55f0adab52
3 changed files with 14 additions and 7 deletions

View File

@ -851,7 +851,7 @@ Thu Feb 6 10:06:20 CET 2003
<sect2 id="sect_03_04_05"><title>Arithmetic expansion</title>
<para>Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result. The format for arithmetic expansion is:</para><cmdsynopsis><command>$(( EXPRESSION ))</command></cmdsynopsis>
<para>The expression is treated as if it were within double quotes, but a double quote inside the parentheses is not treated specially. All tokens in the expression undergo parameter expansion, command substitution, and quote removal. Arithmetic substitutions may be nested.</para>
<para>Evaluation of arithmetic expressions is done in fixed-width integers with no check for overflow - although division by zero is trapped and recognized as an error. The operators are the same as in the C programming language. In order of decreasing precedence, the list looks like this:</para>
<para>Evaluation of arithmetic expressions is done in fixed-width integers with no check for overflow - although division by zero is trapped and recognized as an error. The operators are roughly the same as in the C programming language. In order of decreasing precedence, the list looks like this:</para>
<table id="table_03_04" frame="all">
<title>Arithmetic operators</title>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
@ -868,7 +868,7 @@ Thu Feb 6 10:06:20 CET 2003
<row><entry>+ and -</entry><entry>addition, subtraction</entry></row>
<row><entry>&lt;&lt; and &gt;&gt;</entry><entry>left and right bitwise shifts</entry></row>
<row><entry>&lt;=, &gt;=, &lt; and &gt;</entry><entry>comparison operators</entry></row>
<row><entry>== and !==</entry><entry>equality and inequality</entry></row>
<row><entry>== and !=</entry><entry>equality and inequality</entry></row>
<row><entry>&amp;</entry><entry>bitwise AND</entry></row>
<row><entry>^</entry><entry>bitwise exclusive OR</entry></row>
<row><entry>|</entry><entry>bitwise OR</entry></row>
@ -904,7 +904,7 @@ leading <quote>0x</quote> or <quote>0X</quote> denotes hexadecimal. Otherwise,
</sect2>
<sect2 id="sect_03_04_07"><title>Word splitting</title>
<para>The shell scans the results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double quotes for word splitting.</para>
<para>The shell treats each character of <varname>$IFS</varname> as a delimiter, and splits the results of the other expansions into words on these characters. If <varname>IF</varname> is unset, or its value is exactly <quote>'&lt;space&gt;&lt;tab&gt;&lt;newline&gt;'</quote>, the default, then any sequence of <varname>IFS</varname> characters serves to delimit words. If <varname>IFS</varname> has a value other than the default, then sequences of the whitespace characters <quote>space</quote> and <quote>Tab</quote> are ignored at the beginning and end of the word, as long as the whitespace character is in the value of <varname>IFS</varname> (an <varname>IFS</varname> whitespace character). Any character in <varname>IFS</varname> that is not <varname>IFS</varname> whitespace, along with any adjacent <varname>IF</varname> whitespace characters, delimits a field. A sequence of <varname>IFS</varname> whitespace characters is also treated as a delimiter. If the value of <varname>IFS</varname> is null, no word splitting occurs.</para>
<para>The shell treats each character of <varname>$IFS</varname> as a delimiter, and splits the results of the other expansions into words on these characters. If <varname>IFS</varname> is unset, or its value is exactly <quote>'&lt;space&gt;&lt;tab&gt;&lt;newline&gt;'</quote>, the default, then any sequence of <varname>IFS</varname> characters serves to delimit words. If <varname>IFS</varname> has a value other than the default, then sequences of the whitespace characters <quote>space</quote> and <quote>Tab</quote> are ignored at the beginning and end of the word, as long as the whitespace character is in the value of <varname>IFS</varname> (an <varname>IFS</varname> whitespace character). Any character in <varname>IFS</varname> that is not <varname>IFS</varname> whitespace, along with any adjacent <varname>IF</varname> whitespace characters, delimits a field. A sequence of <varname>IFS</varname> whitespace characters is also treated as a delimiter. If the value of <varname>IFS</varname> is null, no word splitting occurs.</para>
<para>Explicit null arguments (<quote>""</quote> or <quote>''</quote>) are retained. Unquoted implicit null arguments, resulting from the expansion of parameters that have no values, are removed. If a parameter with no value is expanded within double quotes, a null argument results and is retained.</para>
<note><title>Expansion and word splitting</title><para>If no expansion occurs, no splitting is performed.</para></note>
</sect2>

View File

@ -52,7 +52,7 @@ contain function definitions, loops, conditions and other programming constructs
</figure>
<para>In the output of <command>ls <option>-l</option></command>, there are 9 columns. The <command>print</command> statement uses these fields as follows:</para>
<screen>
<prompt>kelly@octarine ~/test&gt;</prompt> <command>ls <option>-l</option> | awk <parameter>'{ print $9 $5 }'</parameter></command>
<prompt>kelly@octarine ~/test&gt;</prompt> <command>ls <option>-l</option> | awk <parameter>'{ print $5 $9 }'</parameter></command>
160orig
121script.sed
120temp_file

View File

@ -175,7 +175,7 @@ not a local account
<prompt>anny &gt;</prompt> <command>echo <varname>$num</varname></command>
201
<prompt>anny &gt;</prompt> <command>if <parameter>[ "num" &gt; 150 ]</parameter></command>
<prompt>anny &gt;</prompt> <command>if <parameter>[ "$num" -gt "150" ]</parameter></command>
<prompt>More input&gt;</prompt> <command>then echo ; echo <parameter>"you've worked hard enough for today."</parameter></command>
<prompt>More input&gt;</prompt> <command>echo ; fi</command>
@ -211,9 +211,10 @@ fi
</screen>
<para>With Bash, you can shorten this type of construct. The compact equivalent of the above test is as follows:</para>
<screen>
[ "$(whoami)" != 'root' ] &amp;&amp; echo you are using a non-privileged account
[ "$(whoami)" != 'root' ] &amp;&amp; ( echo you are using a non-privileged account; exit 1 )
</screen>
<para>Regular expressions may also be used:</para>
<para>Similar to the <quote>&amp;&amp;</quote> expression which indicates what to do if the test proves true, <quote>||</quote> specifies what to do if the test is false.</para>
<para>Regular expressions may also be used in comparisons:</para>
<screen>
<prompt>anny &gt;</prompt> <command><varname>gender</varname>=<parameter>"female"</parameter></command>
@ -223,6 +224,12 @@ Pleasure to meet you, Madame.
<prompt>anny &gt;</prompt>
</screen>
<note><title>Real Programmers</title>
<para>Most programmers will prefer to use the <command>test</command> built-in command, which is equivalent to using square brackets for comparison, like this:</para>
<screen>
test "$(whoami)" != 'root' &amp;&amp; (echo you are using a non-privileged account; exit 1)
</screen>
</note>
<para>See the info pages for Bash for more information on pattern matching with the <quote>(( EXPRESSION ))</quote> and <quote>[[ EXPRESSION ]]</quote> constructs.</para>
</sect3>
</sect2>