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

<p>
<tt>elgetopt</tt> performs <tt>getopt</tt>-style parsing on the
arguments to an execline script.
</p>

<h2> Interface </h2>

<pre>
     elgetopt [ -D <em>default</em> ] <em>optstring</em> <em>prog...</em>
</pre>

<ul>
 <li> <tt>elgetopt</tt> expects to find a valid number <em>n</em> of
arguments in the <tt>#</tt> environment variable, and <em>n</em>+1
environment variables <tt>0</tt>, <tt>1</tt>, ..., <tt><em>n</em></tt>.
It exits 100 if it is not the case. </li>
 <li> <tt>elgetopt</tt> <a href="el_pushenv.html">pushes</a>
environment variables starting with <tt>ELGETOPT_</tt>. To get the
previous values back, use
<a href="emptyenv.html"><tt>emptyenv&nbsp;-o</tt></a>. </li>
 <li> <tt>elgetopt</tt> looks into <tt>1</tt>, <tt>2</tt>... for options,
as specified by <em>optstring</em>, which is a standard <tt>getopt</tt>
string. </li>
 <li> If the <tt>-<em>c</em></tt> switch is recognized, <tt>elgetopt</tt>
sets the <tt>ELGETOPT_<em>c</em></tt> environment variable. The value
of that variable is the argument to the <tt>-<em>c</em></tt> switch if
it has one, and <tt>1</tt> (or <em>default</em> if given) otherwise. </li>
 <li> After setting all recognized options, <tt>elgetopt</tt> makes
new <tt>#</tt>, <tt>1</tt>, <tt>2</tt>... "positional parameters" with
what remains. </li>
 <li> <tt>elgetopt</tt> then execs into <em>prog...</em>. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-D&nbsp;<em>default</em></tt>&nbsp;: use <em>default</em> as the
value for the <tt>ELGETOPT_<em>c</em></tt> environment variable if there is
no argument to the <tt>-<em>c</em></tt> switch. Default is <tt>1</tt>. The
value is the same for all the options defined by elgetopt. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> GNU-style options are not supported. </li>
</ul>

</body>
</html>