help for needs to mention for ((...))
$ help for only mentions for name [ [ in [ word ... ] ] ; ] do list ; done and needs to be updated to mention for (( expr1 ; expr2 ; expr3 )) ; do list ; done $ echo $BASH_VERSION 5.1.8(1)-release
Re: help for needs to mention for ((...))
On Sun, Sep 19, 2021, at 3:25 PM, 積丹尼 Dan Jacobson wrote: > $ help for > only mentions >for name [ [ in [ word ... ] ] ; ] do list ; done > and needs to be updated to mention >for (( expr1 ; expr2 ; expr3 )) ; do list ; done Not particularly intuitive, but: bash-5.1$ help 'for ((' for ((: for (( exp1; exp2; exp3 )); do COMMANDS; done Arithmetic for loop. Equivalent to (( EXP1 )) while (( EXP2 )); do COMMANDS (( EXP3 )) done EXP1, EXP2, and EXP3 are arithmetic expressions. If any expression is omitted, it behaves as if it evaluates to 1. Exit Status: Returns the status of the last command executed. -- vq
Re: help for needs to mention for ((...))
On Sun, Sep 19, 2021, 4:07 PM Lawrence Velázquez wrote: > On Sun, Sep 19, 2021, at 3:25 PM, 積丹尼 Dan Jacobson wrote: > > $ help for > > only mentions > >for name [ [ in [ word ... ] ] ; ] do list ; done > > and needs to be updated to mention > >for (( expr1 ; expr2 ; expr3 )) ; do list ; done > > Not particularly intuitive, but: > > bash-5.1$ help 'for ((' > for ((: for (( exp1; exp2; exp3 )); do COMMANDS; done > Arithmetic for loop. > > Equivalent to > (( EXP1 )) > while (( EXP2 )); do > COMMANDS > (( EXP3 )) > done > EXP1, EXP2, and EXP3 are arithmetic expressions. If any expression is > omitted, it behaves as if it evaluates to 1. > > Exit Status: > Returns the status of the last command executed. > > -- > vq > And help 'for*' (No space) gets them both. >
Re: help for needs to mention for ((...))
OK, then "help for" should at least mention that trick to get the rest of the story.
Re: help for needs to mention for ((...))
$ help f|wc -l 72 $ help fo |wc -l 24 $ help for |wc -l 10 $ help for\ |wc -l 14 $ help for\ \( |wc -l 14 $ help for\ \(\(|wc -l 14 So help help's 'If PATTERN is specified, gives detailed help on all commands matching PATTERN." is not telling the whole story about matching.
Re: help for needs to mention for ((...))
OK, so it first looks for exact hits, then does a grep style match. And we see that $ help f|grep :. false: false fc: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command] fg: fg [job_spec] for: for NAME [in WORDS ... ] ; do COMMANDS; done for ((: for (( exp1; exp2; exp3 )); do COMMANDS; done function: function name { COMMANDS ; } or name () { COMMANDS ; } the function name is 'for ((' not 'for (( ))' etc. Great.