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 forstdin command</title>
<meta name="Description" content="execline: the forstdin command" />
<meta name="Keywords" content="execline command forstdin" />
<!-- <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>forstdin</tt> program </h1>
<p>
<tt>forstdin</tt> uses its input as loop elements to
run another program.
</p>
<h2> Interface </h2>
<p>
In an <a href="execlineb.html">execlineb</a> script:
</p>
<pre>
forstdin [ -p | -o <em>okcodes</em> | -x <em>breakcodes</em> ] [ -e eofcode ] [ -n ] [ -C | -c ] [ -0 | -d <em>delim</em> ] <em>variable</em> <em>loop...</em>
</pre>
<ul>
<li> <tt>forstdin</tt> reads its standard input as it becomes available,
<a href="el_transform.html#split">splitting</a> it automatically. </li>
<li> For every argument <em>x</em> in the split output,
<tt>forstdin</tt> runs <em>loop...</em> as a child process, with
<em>variable</em>=<em>x</em> added to its environment. </li>
<li><tt>forstdin</tt> then exits 0.
</ul>
<h2> Options </h2>
<ul>
<li> <tt>-p</tt> : parallel mode. Do not wait for a <em>loop...</em>
instance to finish before spawning the next one. forstdin will
still wait for all instances of <em>loop</em> to terminate before
exiting, though. </li>
<li> <tt>-0</tt> : accept null characters on its stdin,
using them as delimiters. If this option and a <tt>-d</tt> option are
used simultaneously, the rightmost one wins. </li>
<li> <tt>-o</tt> <em>okcodes</em> : <em>okcodes</em> must
be a comma-separated list of exit codes. If the <tt>-p</tt> flag
hasn't been given and <em>loop</em> exits with one of the codes in
<em>okcodes</em>,
forstdin will run the following instances of the loop, but if the exit code is
not listed in <em>okcodes</em>, forstdin will exit immediately with an
<a href="exitcodes.html">approximation</a> of the same exit code. </li>
<li> <tt>-x</tt> <em>breakcodes</em> : like the previous
option, but with inverted meaning - the listed exit codes are codes
that will make forstdin break the loop and exit, and the unlisted exit
codes will make it keep looping. </li>
<li> <tt>-e</tt> <em>eofcode</em> : if forstdin reads EOF,
exit <em>eofcode</em>. Default is 0. </li>
<li> Other options are used to <a href="el_transform.html">control
the substitution mechanism</a> for every <em>x</em>. Of course, you can't
split <em>x</em>. </li>
</ul>
<h2> Notes </h2>
<ul>
<li> You can start <em>loop...</em> with "importas -u <em>variable</em> <em>variable</em>"
to perform variable substitution. </li>
</ul>
</body>
</html>
|