summary refs log tree commit diff
path: root/doc/elgetopt.html
blob: b3a28ce2d6742370bed6deaa5d955196f900e946 (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
<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 <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 1 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> Notes </h2>

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

</body>
</html>