/usr/share/doc/medit-1/help/ch03s03.html is in medit 1.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Shell scripts</title>
<link rel="stylesheet" href="medit.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="medit manual">
<link rel="up" href="ch03.html" title="Chapter 3. User-defined tools">
<link rel="prev" href="ch03s02.html" title="Storing tools in files">
<link rel="next" href="ch03s04.html" title="Lua scripts">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Shell scripts</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="ch03s02.html">Prev</a> </td>
<th width="60%" align="center">Chapter 3. User-defined tools</th>
<td width="20%" align="right"> <a accesskey="n" href="ch03s04.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Shell scripts">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="section-user-tools-shell"></a>Shell scripts</h2></div></div></div>
<p>
Shell script user tools execute command entered in the <span class="guilabel">Command</span>
text field using default user shell on Unix systems or <span class="command"><strong>cmd.exe</strong></span> on Windows.
</p>
<p>
Its input and output are specified by the following controls:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<em class="parameter"><code><span class="guilabel">Input</span></code></em> entry specifies what text from the document should be passed to the command.
The text is passed via command's standard input, except for <em class="parameter"><code>Document copy</code></em> case.
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>None</code></em></span></p></td>
<td>no input text.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Selected lines</code></em></span></p></td>
<td>the lines containing selection or the line containing the cursor in
case when no text is selected.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Selection</code></em></span></p></td>
<td>exact selected text. This will be different from <em class="parameter"><code>Selected lines</code></em>
if selection does not span whole lines of the document, for instance if it is a single word.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Whole document</code></em></span></p></td>
<td>whole document contents.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Document copy</code></em></span></p></td>
<td>document contents will be saved to a temporary file and the file path will be stored
in <code class="envar">INPUT_FILE</code> environment variable. No text will be passed to the command via standard
input.</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<em class="parameter"><code><span class="guilabel">Output</span></code></em> entry specifies how the standard output of the command should be redirected.
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>None</code></em></span></p></td>
<td>the command output will be discarded.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>None, asynchronous</code></em></span></p></td>
<td>the command output will be discarded, and the command will be executed in background.
Use this if you need to launch some external program like a web browser.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Output pane</code></em></span></p></td>
<td>the command output will be displayed in an output pane. This is useful for running programs
like compilers, where you want to see the output.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Insert into the document</code></em></span></p></td>
<td>output will be inserted into the current document at the cursor position. It will replace the
text used as an input, if any.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>New document</code></em></span></p></td>
<td>new document will be created and the command output will be inserted into it.</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<em class="parameter"><code><span class="guilabel">Filter</span></code></em> combo. If the output pane is used, then it can be passed through a
<em class="parameter"><code>filter</code></em>: the filter can match filenames and line numbers, so when you click
the text in the output pane it will open the corresponding file. This is used for compilers and
similar commands, which output locations of errors in processed files.
</li>
</ul></div>
<p>
</p>
<p>
Shell script user tools have a number of environment variables set.
<code class="envar">APP_PID</code> variable is set so that opening a file in the same instance
of <span class="application">medit</span> is as simple as <code class="code">medit filename</code> (on the other hand, you will
have to use command line options if you need to run a new <span class="application">medit</span> instance). The
following environment variables are set when scripts are executed:
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><code class="envar">APP_PID</code></span></p></td>
<td>current process id.</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">DOC</code></span></p></td>
<td>document basename ("<code class="filename">file.c</code>" for file <code class="filename">/home/user/file.c</code>).</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">DOC_DIR</code></span></p></td>
<td>document directory ("<code class="filename">/home/user</code>" for file <code class="filename">/home/user/file.c</code>). Full file path is
<code class="filename"><code class="envar">$DOC_DIR</code>/<code class="envar">$DOC</code></code>.</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">DOC_BASE</code></span></p></td>
<td>basename without extension ("<code class="filename">file</code>" for file <code class="filename">/home/user/file.c</code>).</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">DOC_EXT</code></span></p></td>
<td>document filename extension including the period ("<code class="filename">.c</code>" for file
<code class="filename">/home/user/file.c</code>). Basename is always
<code class="filename"><code class="envar">$DOC_BASE</code><code class="envar">$DOC_EXT</code></code>.</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">DOC_PATH</code></span></p></td>
<td>full document path.</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">LINE</code></span></p></td>
<td>
<code class="constant">1</code>-based number of the line containing cursor.
For example, if cursor is at the first line then <code class="envar">LINE</code> will be
set to <code class="constant">1</code>.</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">LINE0</code></span></p></td>
<td>
<code class="constant">0</code>-based number of the line containing cursor.
For example, if cursor is at the first line then <code class="envar">LINE0</code> will be
set to <code class="constant">0</code>.</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">DATA_DIR</code></span></p></td>
<td>user data directory (<code class="filename">$HOME/.local/share/medit-1/</code> on Unix systems).</td>
</tr>
<tr>
<td><p><span class="term"><code class="envar">INPUT_FILE</code></span></p></td>
<td>if <em class="parameter"><code>input</code></em> was set to "Document copy" then this is set to
full path of the temporary file containing document text.</td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p>
Additionally, all shell commands which run inside <span class="application">medit</span> will have
<code class="filename"><code class="envar">DATA_DIR</code>/scripts</code>
directories in <code class="envar">$PATH</code>, so you may place some <span class="application">medit</span>-specific programs
or scripts into <code class="filename"><code class="envar">DATA_DIR</code>/scripts/</code> to be used from shell script tools.
</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="ch03s02.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="ch03s04.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Storing tools in files </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Lua scripts</td>
</tr>
</table>
</div>
</body>
</html>
|