about summary refs log tree commit diff
path: root/doc/forx.html
blob: 8f1d558a4e33673e75afbae35428d191ae9178fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta http-equiv="Content-Language" content="en" />
  <title>execline: the forx command</title>
  <meta name="Description" content="execline: the forx command" />
  <meta name="Keywords" content="execline command forx" />
  <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
 </head>
<body>

<p>
<a href="index.html">execline</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The <tt>forx</tt> program </h1>

<p>
<tt>forx</tt> runs a loop.
</p>

<h2> Interface </h2>

<p>
 In an <a href="execlineb.html">execlineb</a> script:
</p>

<pre>
     forx [ -E | -e ] [ -p ] [ -o <em>okcodes</em> | -x <em>breakcodes</em> ] <em>variable</em> { <em>args...</em> } <em>loop...</em>
</pre>

<ul>
 <li> <tt>forx</tt> reads a
<a href="el_semicolon.html">block</a> and unquotes it.
That block contains a list of <em>args</em>. </li>
 <li> For each argument <em>x</em> in <em>args...</em>,
<tt>forx</tt> runs <em>loop</em> as a child process, with
<em>variable</em>=<em>x</em> added to its environment. </li>
 <li> <tt>forx</tt> then exits 0. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-o</tt>&nbsp;<em>okcodes</em>&nbsp;: <em>okcodes</em> must
be a comma-separated list of exit codes. If
<em>loop</em> exits with one of the codes in <em>okcodes</em>,
forx will run the following instances of the loop, but if the exit code is
not listed in <em>okcodes</em>, forx will exit immediately with an
<a href="exitcodes.html">approximation</a> of the same exit code. </li>
 <li> <tt>-x</tt>&nbsp;<em>breakcodes</em>&nbsp;: like the previous
option, but with inverted meaning - the listed exit codes are codes
that will make forx break the loop and exit, and the unlisted exit
codes will make it keep looping. </li>
 <li> <tt>-p</tt>&nbsp;: run in parallel. Do not wait for an instance of
<em>loop...</em> to exit before spawning the next one. <tt>forx</tt>
will still wait for all instances of <em>loop</em> to terminate before
exiting 0. If the <tt>-o</tt> option has been given, <tt>forx</tt>
will exit 0 if all of the exit codes are in the values listed in the <em>okcodes</em>
list, else it will exit 1. If the <tt>-x</tt> option has been given,
<tt>forx</tt> will exit 0 if none of the exit codes are in the values
listed in the <em>breakcodes</em> list, else it will exit 1. </li>
 <li> <tt>-e</tt>&nbsp;: no autoimport. This is the default. </li>
 <li> <tt>-E</tt>&nbsp;: autoimport. Instead of spawning
<em>loop...</em>, spawn <tt>importas -ui <em>variable</em> <em>variable</em>
<em>loop...</em></tt>. This substitutes <em>variable</em> into the command
line instead of putting it into the environment. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> You can start <em>loop</em> with "importas -u <em>variable</em> <em>variable</em>"
if you want variable substitution. </li>
</ul>

</body>
</html>