summaryrefslogtreecommitdiff
path: root/doc/importas.html
blob: ac95e875586c030055309ccfd2df7d731fbded8c (plain)
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
<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 importas program</title>
    <meta name="Description" content="execline: the importas program" />
    <meta name="Keywords" content="execline command importas import environment variable" />
    <!-- <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>importas</tt> program </h1>

<p>
<tt>importas</tt> replaces a literal with the value of an
environment variable, then executes another program.
</p>

<h2> Interface </h2>

<pre>
     importas [ -i | -D default ] [ -u ] [ -s ] [ -C | -c ] [ -N | -n ] [ -d <em>delim</em> ] <em>variable</em> <em>envvar</em> <em>prog...</em>
</pre>

<ul>
 <li> <tt>importas</tt> fetches the value of <em>envvar</em> in the
environment. If neither the <em>-D</em> nor the <em>-i</em> option is given,
and <em>envvar</em> is undefined, <strong>no word</strong> is returned
(that is different from the empty word). </li>
 <li> <tt>importas</tt> then performs
<a href="el_substitute.html">variable substitution</a> on <em>prog...</em>,
with <em>variable</em> as key and that string as value.
 <li><tt>importas</tt> then execs into the modified <em>prog...</em>. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-D</tt>&nbsp;<em>default</em>&nbsp;: If this option is given and
<em>envvar</em> is undefined, substitute <em>default</em> for the value of
<em>variable</em> instead of no word. For instance, to substitute
the empty word, use <tt>-D&nbsp;""</tt>. </li>
 <li> <tt>-i</tt>&nbsp;: Insist. If <em>envvar</em> is undefined,
<tt>importas</tt> will not do anything; instead, it will exit 100 with an
error message. This has precedence over any <tt>-D</tt> option. </li>
 <li> <tt>-u</tt>&nbsp;: Unexport. <em>envvar</em> will be removed from
the environment after the substitution. <tt>importas -u <em>variable</em>
<em>envvar</em></tt> is equivalent to <tt>importas <em>variable</em>
<em>envvar</em> unexport <em>envvar</em></tt>. </li>
 <li> Other options are used to <a href="el_transform.html">control
the substitution mechanism</a>. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> When <em>envvar</em> is undefined, and the <tt>-D</tt> option is
not given, any <a href="el_substitute.html">variable substitution</a>
with <em>variable</em> as the key will return no word; that is true
even when the <tt>${<em>variable</em>}</tt> form to be substituted
happens in the middle of a word (with a prefix and/or a postfix), which
means the whole word will be deleted. If this is not the behaviour
you want, use the <tt>-D</tt> option. </li>
</ul>

</body>
</html>