about summary refs log tree commit diff
path: root/doc/withstdinas.html
blob: 5b9e653e63203bf3e98fa41969e260eebda150c7 (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
<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 withstdinas command</title>
 <meta name="Description" content="execline: the withstdinas command" />
 <meta name="Keywords" content="execline command withstdinas" />
 <!-- <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>withstdinas</tt> program </h1>

<p>
<tt>withstdinas</tt> reads the entirety of its standard input in an
environment variable, and runs another program with that additional
environment variable.
</p>

<h2> Interface </h2>

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

<pre>
     withstdinas [ -i | -I | -D <em>default</em> ] [ -N | -n ] [ -E | -e ] <em>variable</em> <em>prog...</em>
</pre>

<ul>
 <li> <tt>withstdinas</tt> reads its stdin until EOF. </li>
 <li> It then execs into <em>prog...</em>, with
<em>variable</em> added to the environment; the value of
<em>variable</em> is what was read on stdin. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-N</tt>&nbsp;: do not chomp an ending newline off stdin. </li>
 <li> <tt>-n</tt>&nbsp;: chomp an ending newline off stdin. This is the default. </li>
 <li> <tt>-e</tt>&nbsp;: no autoimport. This is the default. </li>
 <li> <tt>-E</tt>&nbsp;: autoimport. Instead of exec'ing into
<em>prog...</em>, exec into <tt>importas -ui <em>variable</em> <em>variable</em>
<em>prog...</em></tt>. This substitutes <em>variable</em> into the command
line instead of putting it into the environment. </li>
</ul>

<p>
 The other options tell withstdinas what to do if its input is
not suitable as the contents of an environment variable, i.e. it
contains a null character:
</p>

<ul>
 <li> <tt>-i</tt>&nbsp;: withstdinas exits 1. </li>
 <li> <tt>-I</tt>&nbsp;: <em>variable</em> is <strong>removed</strong> from
the environment, and execution proceeds. </li>
 <li> <tt>-D&nbsp;<em>default</em></tt>&nbsp;: the value of <em>variable</em>
is set to <em>default</em>, and execution proceeds. </li>
 <li> neither of those options:  the value of <em>variable</em> is set to whatever the
start of the input is, up to the first null character; and execution proceeds. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> You can start <em>prog...</em> with "importas -u <em>variable</em> <em>variable</em>"
to perform variable substitution. </li>
</ul>

</body>
</html>