Print this page
8858 /usr/bin/grep doesn't support -E option
4580 /usr/bin/grep can't handle multibyte characters
8929 8868 tests are not delivered with system/test/utiltest
8860 Example in grep(1) is incorrect
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>


 335 <literal>|fork()|+|exec()|</literal>'s:
 336 <programlisting>
 337 if [[ "${x}" == ~(E).*foo.* ]] ; then
 338     do_something ;
 339 done
 340 </programlisting>
 341           </para>
 342       </section>
 343 
 344 
 345       <section xml:id="use_dashdash_if_first_arg_is_variable">
 346           <title>If the first operand of a command is a variable, use <literal>--</literal></title>
 347           <para>If the first operand of a command is a variable, use <literal>--</literal>
 348           for any command that accepts this as end of argument to
 349           avoid problems if the variable expands to a value starting with <literal>-</literal>.
 350           </para>
 351           <note><para>
 352           At least
 353           <simplelist type="inline">
 354               <member>print</member>
 355               <member>/usr/bin/fgrep</member><member>/usr/xpg4/bin/fgrep</member>
 356               <member>/usr/bin/grep</member> <member>/usr/xpg4/bin/grep</member>
 357               <member>/usr/bin/egrep</member><member>/usr/xpg4/bin/egrep</member>
 358           </simplelist>
 359           support <literal>--</literal> as "end of arguments"-terminator.
 360           </para></note>
 361       </section>
 362 
 363       <section xml:id="use_export">
 364           <title>&tag_kshonly;&tag_performance;Use <literal>$ export FOOBAR=val #</literal> instead of
 365           <literal>$ FOOBAR=val ; export FOOBAR #</literal></title>
 366           <para>Use <literal>$ export FOOBAR=val # instead of $ FOOBAR=val ; export FOOBAR #</literal> -
 367           this is much faster.</para>
 368       </section>
 369 
 370 
 371       <section xml:id="use_subshell_around_set_dashdash_usage">
 372           <title>Use a subshell (e.g. <literal>$ ( mycmd ) #</literal>) around places which use
 373               <literal>set -- $(mycmd)</literal> and/or <literal>shift</literal></title>
 374           <para>Use a subshell (e.g. <literal>$ ( mycmd ) #</literal>) around places which use
 375           <literal>set -- $(mycmd)</literal> and/or <literal>shift</literal> unless the variable
 376           affected is either a local one or if it's guaranteed that this variable will no longer be used
 377           (be careful for loadable functions, e.g. ksh/ksh93's <literal>autoload</literal> !!!!)




 335 <literal>|fork()|+|exec()|</literal>'s:
 336 <programlisting>
 337 if [[ "${x}" == ~(E).*foo.* ]] ; then
 338     do_something ;
 339 done
 340 </programlisting>
 341           </para>
 342       </section>
 343 
 344 
 345       <section xml:id="use_dashdash_if_first_arg_is_variable">
 346           <title>If the first operand of a command is a variable, use <literal>--</literal></title>
 347           <para>If the first operand of a command is a variable, use <literal>--</literal>
 348           for any command that accepts this as end of argument to
 349           avoid problems if the variable expands to a value starting with <literal>-</literal>.
 350           </para>
 351           <note><para>
 352           At least
 353           <simplelist type="inline">
 354               <member>print</member>
 355               <member>/usr/bin/fgrep</member>
 356               <member>/usr/bin/grep</member>
 357               <member>/usr/bin/egrep</member>
 358           </simplelist>
 359           support <literal>--</literal> as "end of arguments"-terminator.
 360           </para></note>
 361       </section>
 362 
 363       <section xml:id="use_export">
 364           <title>&tag_kshonly;&tag_performance;Use <literal>$ export FOOBAR=val #</literal> instead of
 365           <literal>$ FOOBAR=val ; export FOOBAR #</literal></title>
 366           <para>Use <literal>$ export FOOBAR=val # instead of $ FOOBAR=val ; export FOOBAR #</literal> -
 367           this is much faster.</para>
 368       </section>
 369 
 370 
 371       <section xml:id="use_subshell_around_set_dashdash_usage">
 372           <title>Use a subshell (e.g. <literal>$ ( mycmd ) #</literal>) around places which use
 373               <literal>set -- $(mycmd)</literal> and/or <literal>shift</literal></title>
 374           <para>Use a subshell (e.g. <literal>$ ( mycmd ) #</literal>) around places which use
 375           <literal>set -- $(mycmd)</literal> and/or <literal>shift</literal> unless the variable
 376           affected is either a local one or if it's guaranteed that this variable will no longer be used
 377           (be careful for loadable functions, e.g. ksh/ksh93's <literal>autoload</literal> !!!!)