Fortran · 57747 bytes Raw Blame History
1 ! ==============================================================================
2 ! Module: builtin_help_texts
3 ! Per-builtin help text for `help <builtin>` command
4 ! ==============================================================================
5 module builtin_help_texts
6 use iso_fortran_env, only: output_unit
7 implicit none
8 private
9 public :: print_builtin_help
10
11 contains
12
13 function print_builtin_help(name) result(found)
14 character(len=*), intent(in) :: name
15 logical :: found
16 integer :: u
17
18 u = output_unit
19 found = .true.
20
21 select case (trim(name))
22 ! Navigation & Directories
23 case ('cd')
24 call help_cd(u)
25 case ('pwd')
26 call help_pwd(u)
27 case ('pushd')
28 call help_pushd(u)
29 case ('popd')
30 call help_popd(u)
31 case ('dirs')
32 call help_dirs(u)
33 case ('prevd')
34 call help_prevd(u)
35 case ('nextd')
36 call help_nextd(u)
37 case ('dirh')
38 call help_dirh(u)
39 ! Variables & Environment
40 case ('export')
41 call help_export(u)
42 case ('unset')
43 call help_unset(u)
44 case ('readonly')
45 call help_readonly(u)
46 case ('declare', 'typeset')
47 call help_declare(u)
48 case ('local')
49 call help_local(u)
50 case ('printenv')
51 call help_printenv(u)
52 case ('set')
53 call help_set(u)
54 case ('shopt')
55 call help_shopt(u)
56 ! I/O & Formatting
57 case ('echo')
58 call help_echo(u)
59 case ('printf')
60 call help_printf(u)
61 case ('read')
62 call help_read(u)
63 ! Job Control
64 case ('jobs')
65 call help_jobs(u)
66 case ('fg')
67 call help_fg(u)
68 case ('bg')
69 call help_bg(u)
70 case ('kill')
71 call help_kill(u)
72 case ('wait')
73 call help_wait(u)
74 case ('coproc')
75 call help_coproc(u)
76 ! Shell Features
77 case ('source', '.')
78 call help_source(u)
79 case ('eval')
80 call help_eval(u)
81 case ('exec')
82 call help_exec(u)
83 case ('command')
84 call help_command(u)
85 case ('type')
86 call help_type(u)
87 case ('which')
88 call help_which(u)
89 case ('hash')
90 call help_hash(u)
91 case ('trap')
92 call help_trap(u)
93 case ('history')
94 call help_history(u)
95 case ('fc')
96 call help_fc(u)
97 case ('alias')
98 call help_alias(u)
99 case ('unalias')
100 call help_unalias(u)
101 case ('abbr')
102 call help_abbr(u)
103 case ('config')
104 call help_config(u)
105 ! Scripting & Control Flow
106 case ('test', '[')
107 call help_test(u)
108 case ('break')
109 call help_break(u)
110 case ('continue')
111 call help_continue(u)
112 case ('return')
113 call help_return(u)
114 case ('shift')
115 call help_shift(u)
116 case ('getopts')
117 call help_getopts(u)
118 case ('let')
119 call help_let(u)
120 case ('exit')
121 call help_exit(u)
122 ! System & Completion
123 case ('umask')
124 call help_umask(u)
125 case ('ulimit')
126 call help_ulimit(u)
127 case ('times')
128 call help_times(u)
129 case ('complete')
130 call help_complete(u)
131 case ('compgen')
132 call help_compgen(u)
133 ! Utilities
134 case ('perf')
135 call help_perf(u)
136 case ('memory')
137 call help_memory(u)
138 case ('defun')
139 call help_defun(u)
140 case ('timeout')
141 call help_timeout(u)
142 case ('help')
143 call help_help(u)
144 case ('true')
145 call help_true(u)
146 case ('false')
147 call help_false(u)
148 case (':')
149 call help_colon(u)
150 case default
151 found = .false.
152 end select
153 end function print_builtin_help
154
155 ! --------------------------------------------------------------------------
156 ! Navigation & Directories
157 ! --------------------------------------------------------------------------
158
159 subroutine help_cd(u)
160 integer, intent(in) :: u
161 write(u, '(a)') 'cd: cd [-L|-P] [dir]'
162 write(u, '(a)') ' Change the shell working directory.'
163 write(u, '(a)') ''
164 write(u, '(a)') ' Change the current directory to DIR. The default DIR is the value'
165 write(u, '(a)') ' of the HOME shell variable. A DIR of - is equivalent to $OLDPWD.'
166 write(u, '(a)') ''
167 write(u, '(a)') ' Options:'
168 write(u, '(a)') ' -L follow symbolic links (default)'
169 write(u, '(a)') ' -P use physical directory structure without following symlinks'
170 write(u, '(a)') ''
171 write(u, '(a)') ' The variable CDPATH defines the search path for the directory'
172 write(u, '(a)') ' containing DIR. CDPATH entries are separated by colons.'
173 write(u, '(a)') ' A null directory name is the same as the current directory.'
174 write(u, '(a)') ''
175 write(u, '(a)') ' Exit Status:'
176 write(u, '(a)') ' Returns 0 if the directory is changed, 1 otherwise.'
177 end subroutine help_cd
178
179 subroutine help_pwd(u)
180 integer, intent(in) :: u
181 write(u, '(a)') 'pwd: pwd [-LP]'
182 write(u, '(a)') ' Print the name of the current working directory.'
183 write(u, '(a)') ''
184 write(u, '(a)') ' Options:'
185 write(u, '(a)') ' -L print the value of $PWD if it names the current working'
186 write(u, '(a)') ' directory (default)'
187 write(u, '(a)') ' -P print the physical directory, without any symbolic links'
188 write(u, '(a)') ''
189 write(u, '(a)') ' Exit Status:'
190 write(u, '(a)') ' Returns 0 unless an invalid option is given or the current directory'
191 write(u, '(a)') ' cannot be read.'
192 end subroutine help_pwd
193
194 subroutine help_pushd(u)
195 integer, intent(in) :: u
196 write(u, '(a)') 'pushd: pushd [-n] [dir]'
197 write(u, '(a)') ' Add a directory to the directory stack.'
198 write(u, '(a)') ''
199 write(u, '(a)') ' Save the current directory on the top of the directory stack'
200 write(u, '(a)') ' and then cd to DIR. With no arguments, exchanges the top two'
201 write(u, '(a)') ' directories on the stack.'
202 write(u, '(a)') ''
203 write(u, '(a)') ' Options:'
204 write(u, '(a)') ' -n Suppresses the normal change of directory; only manipulates'
205 write(u, '(a)') ' the stack'
206 write(u, '(a)') ''
207 write(u, '(a)') ' Tilde (~) in DIR is expanded to $HOME.'
208 write(u, '(a)') ' Maximum stack depth is 32 directories.'
209 write(u, '(a)') ''
210 write(u, '(a)') ' Exit Status:'
211 write(u, '(a)') ' Returns 0 on success, 1 if cd fails or stack is full.'
212 end subroutine help_pushd
213
214 subroutine help_popd(u)
215 integer, intent(in) :: u
216 write(u, '(a)') 'popd: popd [-n] [+N | -N]'
217 write(u, '(a)') ' Remove a directory from the directory stack.'
218 write(u, '(a)') ''
219 write(u, '(a)') ' Remove the top entry from the directory stack and cd to the new'
220 write(u, '(a)') ' top directory. With no arguments, removes the top directory and'
221 write(u, '(a)') ' changes to the new top entry.'
222 write(u, '(a)') ''
223 write(u, '(a)') ' Options:'
224 write(u, '(a)') ' -n Suppresses the normal change of directory; only manipulates'
225 write(u, '(a)') ' the stack'
226 write(u, '(a)') ''
227 write(u, '(a)') ' Arguments:'
228 write(u, '(a)') ' +N Removes the Nth entry counting from the top of the stack'
229 write(u, '(a)') ' -N Removes the Nth entry counting from the bottom'
230 write(u, '(a)') ''
231 write(u, '(a)') ' When a numeric argument is given, the entry is removed without'
232 write(u, '(a)') ' changing the current directory.'
233 write(u, '(a)') ''
234 write(u, '(a)') ' Exit Status:'
235 write(u, '(a)') ' Returns 0 on success, 1 if the stack is empty or index is invalid.'
236 end subroutine help_popd
237
238 subroutine help_dirs(u)
239 integer, intent(in) :: u
240 write(u, '(a)') 'dirs: dirs [-clpv]'
241 write(u, '(a)') ' Display the directory stack.'
242 write(u, '(a)') ''
243 write(u, '(a)') ' Display the list of currently remembered directories. Directories'
244 write(u, '(a)') ' are added with the pushd command and removed with the popd command.'
245 write(u, '(a)') ''
246 write(u, '(a)') ' Options:'
247 write(u, '(a)') ' -c Clear the directory stack'
248 write(u, '(a)') ' -l Long listing (full paths, no tilde abbreviation)'
249 write(u, '(a)') ' -p Print one entry per line'
250 write(u, '(a)') ' -v Verbose: print numbered stack entries, one per line'
251 write(u, '(a)') ''
252 write(u, '(a)') ' Exit Status:'
253 write(u, '(a)') ' Returns 0 unless an invalid option is given.'
254 end subroutine help_dirs
255
256 subroutine help_prevd(u)
257 integer, intent(in) :: u
258 write(u, '(a)') 'prevd: prevd'
259 write(u, '(a)') ' Navigate to the previous directory in the directory stack.'
260 write(u, '(a)') ''
261 write(u, '(a)') ' Exit Status:'
262 write(u, '(a)') ' Returns 0 on success, 1 if the stack is empty.'
263 end subroutine help_prevd
264
265 subroutine help_nextd(u)
266 integer, intent(in) :: u
267 write(u, '(a)') 'nextd: nextd'
268 write(u, '(a)') ' Navigate to the next directory in the directory stack.'
269 write(u, '(a)') ''
270 write(u, '(a)') ' Exit Status:'
271 write(u, '(a)') ' Returns 0 on success, 1 if the stack is empty.'
272 end subroutine help_nextd
273
274 subroutine help_dirh(u)
275 integer, intent(in) :: u
276 write(u, '(a)') 'dirh: dirh'
277 write(u, '(a)') ' Display the directory history.'
278 write(u, '(a)') ''
279 write(u, '(a)') ' Shows a numbered list of recently visited directories.'
280 write(u, '(a)') ''
281 write(u, '(a)') ' Exit Status:'
282 write(u, '(a)') ' Returns 0.'
283 end subroutine help_dirh
284
285 ! --------------------------------------------------------------------------
286 ! Variables & Environment
287 ! --------------------------------------------------------------------------
288
289 subroutine help_export(u)
290 integer, intent(in) :: u
291 write(u, '(a)') 'export: export [-fn] [name[=value] ...]'
292 write(u, '(a)') ' Set export attribute for shell variables.'
293 write(u, '(a)') ''
294 write(u, '(a)') ' Marks each NAME for automatic export to the environment of'
295 write(u, '(a)') ' subsequently executed commands. If VALUE is supplied, assign'
296 write(u, '(a)') ' VALUE before exporting.'
297 write(u, '(a)') ''
298 write(u, '(a)') ' Options:'
299 write(u, '(a)') ' -f Refer to shell functions'
300 write(u, '(a)') ' -n Remove the export property from each NAME'
301 write(u, '(a)') ' -p Display all exported variables and functions'
302 write(u, '(a)') ''
303 write(u, '(a)') ' With no arguments, displays all exported variables.'
304 write(u, '(a)') ' Handles PS1 and PS2 by storing in dedicated shell fields.'
305 write(u, '(a)') ''
306 write(u, '(a)') ' Exit Status:'
307 write(u, '(a)') ' Returns 0 unless an invalid option is given or NAME is invalid.'
308 end subroutine help_export
309
310 subroutine help_unset(u)
311 integer, intent(in) :: u
312 write(u, '(a)') 'unset: unset [-fv] [name ...]'
313 write(u, '(a)') ' Unset values and attributes of shell variables and functions.'
314 write(u, '(a)') ''
315 write(u, '(a)') ' For each NAME, remove the corresponding variable or function.'
316 write(u, '(a)') ''
317 write(u, '(a)') ' Options:'
318 write(u, '(a)') ' -f Treat each NAME as a shell function'
319 write(u, '(a)') ' -v Treat each NAME as a shell variable (default)'
320 write(u, '(a)') ''
321 write(u, '(a)') ' Read-only variables cannot be unset.'
322 write(u, '(a)') ''
323 write(u, '(a)') ' Exit Status:'
324 write(u, '(a)') ' Returns 0 unless a NAME is read-only.'
325 end subroutine help_unset
326
327 subroutine help_readonly(u)
328 integer, intent(in) :: u
329 write(u, '(a)') 'readonly: readonly [-p] [name[=value] ...]'
330 write(u, '(a)') ' Mark shell variables as unchangeable.'
331 write(u, '(a)') ''
332 write(u, '(a)') ' Mark each NAME as read-only; the values of these NAMEs may'
333 write(u, '(a)') ' not be changed by subsequent assignment. If VALUE is supplied,'
334 write(u, '(a)') ' assign VALUE before marking as read-only.'
335 write(u, '(a)') ''
336 write(u, '(a)') ' Options:'
337 write(u, '(a)') ' -p Display all read-only variables'
338 write(u, '(a)') ''
339 write(u, '(a)') ' With no arguments, displays all read-only variables.'
340 write(u, '(a)') ''
341 write(u, '(a)') ' Exit Status:'
342 write(u, '(a)') ' Returns 0 unless an invalid option or invalid name is given.'
343 end subroutine help_readonly
344
345 subroutine help_declare(u)
346 integer, intent(in) :: u
347 write(u, '(a)') 'declare: declare [-aAilnrux] [name[=value] ...]'
348 write(u, '(a)') ' Set variable values and attributes.'
349 write(u, '(a)') ''
350 write(u, '(a)') ' Declare variables and give them attributes. If no NAMEs are given,'
351 write(u, '(a)') ' display the values of variables instead.'
352 write(u, '(a)') ''
353 write(u, '(a)') ' Options:'
354 write(u, '(a)') ' -a Make NAMEs indexed arrays'
355 write(u, '(a)') ' -A Make NAMEs associative arrays'
356 write(u, '(a)') ' -i Make NAMEs have the integer attribute'
357 write(u, '(a)') ' -l Convert NAMEs to lower case on assignment'
358 write(u, '(a)') ' -n Make NAMEs a reference to the variable named by value'
359 write(u, '(a)') ' -r Make NAMEs read-only'
360 write(u, '(a)') ' -u Convert NAMEs to upper case on assignment'
361 write(u, '(a)') ' -x Mark NAMEs for export'
362 write(u, '(a)') ' -p Display attributes and values of each NAME'
363 write(u, '(a)') ''
364 write(u, '(a)') ' Using + instead of - turns off the given attribute.'
365 write(u, '(a)') ' When used in a function, declare makes NAMEs local, as with local.'
366 write(u, '(a)') ''
367 write(u, '(a)') ' Exit Status:'
368 write(u, '(a)') ' Returns 0 unless an invalid option or assignment error occurs.'
369 end subroutine help_declare
370
371 subroutine help_local(u)
372 integer, intent(in) :: u
373 write(u, '(a)') 'local: local [name[=value] ...]'
374 write(u, '(a)') ' Define local variables.'
375 write(u, '(a)') ''
376 write(u, '(a)') ' Create a local variable called NAME with value VALUE. local'
377 write(u, '(a)') ' can only be used within a function; it makes the variable NAME'
378 write(u, '(a)') ' have a visible scope restricted to that function and its children.'
379 write(u, '(a)') ''
380 write(u, '(a)') ' Variables are pushed onto a local stack and restored when the'
381 write(u, '(a)') ' function returns.'
382 write(u, '(a)') ''
383 write(u, '(a)') ' Exit Status:'
384 write(u, '(a)') ' Returns 0 unless local is used outside a function or an invalid'
385 write(u, '(a)') ' name is given.'
386 end subroutine help_local
387
388 subroutine help_printenv(u)
389 integer, intent(in) :: u
390 write(u, '(a)') 'printenv: printenv [name ...]'
391 write(u, '(a)') ' Print environment variables.'
392 write(u, '(a)') ''
393 write(u, '(a)') ' With no arguments, prints all environment variables in NAME=VALUE'
394 write(u, '(a)') ' format. With arguments, prints the value of each specified variable.'
395 write(u, '(a)') ''
396 write(u, '(a)') ' Exit Status:'
397 write(u, '(a)') ' Returns 0 if all specified variables exist, 1 if any are missing.'
398 end subroutine help_printenv
399
400 subroutine help_set(u)
401 integer, intent(in) :: u
402 write(u, '(a)') 'set: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]'
403 write(u, '(a)') ' Set or unset values of shell options and positional parameters.'
404 write(u, '(a)') ''
405 write(u, '(a)') ' Change the value of shell attributes and positional parameters,'
406 write(u, '(a)') ' or display the names and values of shell variables.'
407 write(u, '(a)') ''
408 write(u, '(a)') ' Options:'
409 write(u, '(a)') ' -a Mark variables for export (allexport)'
410 write(u, '(a)') ' -e Exit on first error (errexit)'
411 write(u, '(a)') ' -f Disable filename generation (noglob)'
412 write(u, '(a)') ' -m Enable job control (monitor)'
413 write(u, '(a)') ' -n Read commands but do not execute (noexec)'
414 write(u, '(a)') ' -u Treat unset variables as error (nounset)'
415 write(u, '(a)') ' -v Print shell input lines as read (verbose)'
416 write(u, '(a)') ' -x Print commands and arguments (xtrace)'
417 write(u, '(a)') ' -C Disallow output redirection to existing files (noclobber)'
418 write(u, '(a)') ''
419 write(u, '(a)') ' Using + rather than - causes flags to be turned off.'
420 write(u, '(a)') ' Flags can be combined: set -eu is valid.'
421 write(u, '(a)') ''
422 write(u, '(a)') ' Use -o to set options by name:'
423 write(u, '(a)') ' set -o vi Enable vi editing mode'
424 write(u, '(a)') ' set -o emacs Enable emacs editing mode'
425 write(u, '(a)') ' set -o pipefail Pipe returns rightmost non-zero status'
426 write(u, '(a)') ' set -o List all options'
427 write(u, '(a)') ''
428 write(u, '(a)') ' With no options, displays all shell variables.'
429 write(u, '(a)') ' Using -- signals end of options; remaining args become $1, $2, ...'
430 write(u, '(a)') ''
431 write(u, '(a)') ' Exit Status:'
432 write(u, '(a)') ' Returns 0 unless an invalid option is given.'
433 end subroutine help_set
434
435 subroutine help_shopt(u)
436 integer, intent(in) :: u
437 write(u, '(a)') 'shopt: shopt [-su] [optname ...]'
438 write(u, '(a)') ' Set and unset shell options.'
439 write(u, '(a)') ''
440 write(u, '(a)') ' Toggle values of settings controlling optional shell behavior.'
441 write(u, '(a)') ''
442 write(u, '(a)') ' Options:'
443 write(u, '(a)') ' -s Enable (set) each OPTNAME'
444 write(u, '(a)') ' -u Disable (unset) each OPTNAME'
445 write(u, '(a)') ' -p Print all options with current status'
446 write(u, '(a)') ''
447 write(u, '(a)') ' Available options:'
448 write(u, '(a)') ' dotglob Include dot-files in pathname expansion'
449 write(u, '(a)') ' expand_aliases Expand aliases'
450 write(u, '(a)') ' extglob Enable extended pattern matching operators'
451 write(u, '(a)') ' failglob Error if a glob pattern has no matches'
452 write(u, '(a)') ' globstar ** matches all files and zero or more directories'
453 write(u, '(a)') ' nocaseglob Case-insensitive pathname expansion'
454 write(u, '(a)') ' nocasematch Case-insensitive pattern matching in [[ ]] and case'
455 write(u, '(a)') ' nullglob Expand unmatched globs to empty string'
456 write(u, '(a)') ''
457 write(u, '(a)') ' With no options, displays all options with their current status.'
458 write(u, '(a)') ''
459 write(u, '(a)') ' Exit Status:'
460 write(u, '(a)') ' Returns 0, or 1 if an invalid option name is given.'
461 end subroutine help_shopt
462
463 ! --------------------------------------------------------------------------
464 ! I/O & Formatting
465 ! --------------------------------------------------------------------------
466
467 subroutine help_echo(u)
468 integer, intent(in) :: u
469 write(u, '(a)') 'echo: echo [-neE] [arg ...]'
470 write(u, '(a)') ' Write arguments to standard output.'
471 write(u, '(a)') ''
472 write(u, '(a)') ' Display the ARGs, separated by spaces, followed by a newline.'
473 write(u, '(a)') ''
474 write(u, '(a)') ' Options:'
475 write(u, '(a)') ' -n Do not append a trailing newline'
476 write(u, '(a)') ' -e Enable interpretation of backslash escapes'
477 write(u, '(a)') ' -E Disable interpretation of backslash escapes (default)'
478 write(u, '(a)') ''
479 write(u, '(a)') ' Escape sequences (with -e):'
480 write(u, '(a)') ' \\ backslash \a alert (bell)'
481 write(u, '(a)') ' \b backspace \c stop output (no trailing newline)'
482 write(u, '(a)') ' \f form feed \n newline'
483 write(u, '(a)') ' \r carriage return \t horizontal tab'
484 write(u, '(a)') ' \v vertical tab \0nnn octal value'
485 write(u, '(a)') ' \xHH hexadecimal value'
486 write(u, '(a)') ''
487 write(u, '(a)') ' Exit Status:'
488 write(u, '(a)') ' Returns 0 unless a write error occurs.'
489 end subroutine help_echo
490
491 subroutine help_printf(u)
492 integer, intent(in) :: u
493 write(u, '(a)') 'printf: printf FORMAT [ARGUMENTS...]'
494 write(u, '(a)') ' Formats and prints ARGUMENTS under control of the FORMAT.'
495 write(u, '(a)') ''
496 write(u, '(a)') ' FORMAT is a string containing three types of objects: plain'
497 write(u, '(a)') ' characters (copied to stdout), escape sequences (converted and'
498 write(u, '(a)') ' copied), and format specifications, each causing printing of'
499 write(u, '(a)') ' the next successive ARGUMENT.'
500 write(u, '(a)') ''
501 write(u, '(a)') ' Format specifiers:'
502 write(u, '(a)') ' %s string %c single character'
503 write(u, '(a)') ' %d decimal integer %i integer (same as %d)'
504 write(u, '(a)') ' %o octal %x hexadecimal (lowercase)'
505 write(u, '(a)') ' %X hexadecimal (upper) %u unsigned decimal'
506 write(u, '(a)') ' %f floating point %e scientific notation'
507 write(u, '(a)') ' %g auto float/sci %b string with backslash escapes'
508 write(u, '(a)') ' %q shell-quoted string %% literal percent sign'
509 write(u, '(a)') ''
510 write(u, '(a)') ' Modifier flags: -, 0, +, space, #'
511 write(u, '(a)') ' Width and precision: %10s, %.5f, %*d (from argument)'
512 write(u, '(a)') ''
513 write(u, '(a)') ' Integer arguments accept 0x (hex), 0 (octal), and ''A (character).'
514 write(u, '(a)') ' FORMAT is reused as necessary to consume all ARGUMENTS.'
515 write(u, '(a)') ''
516 write(u, '(a)') ' Exit Status:'
517 write(u, '(a)') ' Returns 0 on success, 1 on format/numeric error, 2 on usage error.'
518 end subroutine help_printf
519
520 subroutine help_read(u)
521 integer, intent(in) :: u
522 write(u, '(a)') 'read: read [-rs] [-a array] [-d delim] [-n nchars] [-p prompt] ' // &
523 '[-t timeout] [name ...]'
524 write(u, '(a)') ' Read a line from standard input.'
525 write(u, '(a)') ''
526 write(u, '(a)') ' Reads a single line from standard input. The line is split into'
527 write(u, '(a)') ' fields using IFS, and each field is assigned to the corresponding'
528 write(u, '(a)') ' NAME. Leftover fields go to the last NAME.'
529 write(u, '(a)') ''
530 write(u, '(a)') ' Options:'
531 write(u, '(a)') ' -a array Assign words to sequential indices of ARRAY'
532 write(u, '(a)') ' -d delim Use DELIM to terminate the line instead of newline'
533 write(u, '(a)') ' -n nchars Return after reading NCHARS characters'
534 write(u, '(a)') ' -p prompt Output PROMPT without trailing newline before reading'
535 write(u, '(a)') ' -r Do not allow backslash escapes or line continuation'
536 write(u, '(a)') ' -s Silent mode (do not echo input)'
537 write(u, '(a)') ' -t timeout Time out and return failure after TIMEOUT seconds'
538 write(u, '(a)') ''
539 write(u, '(a)') ' If no NAMEs are supplied, the line is stored in the REPLY variable.'
540 write(u, '(a)') ''
541 write(u, '(a)') ' Exit Status:'
542 write(u, '(a)') ' Returns 0 unless EOF is encountered with no input or an error occurs.'
543 end subroutine help_read
544
545 ! --------------------------------------------------------------------------
546 ! Job Control
547 ! --------------------------------------------------------------------------
548
549 subroutine help_jobs(u)
550 integer, intent(in) :: u
551 write(u, '(a)') 'jobs: jobs [-l]'
552 write(u, '(a)') ' Display status of jobs.'
553 write(u, '(a)') ''
554 write(u, '(a)') ' Lists the active jobs. The -l option provides more information.'
555 write(u, '(a)') ''
556 write(u, '(a)') ' Options:'
557 write(u, '(a)') ' -l List process IDs in addition to the normal information'
558 write(u, '(a)') ''
559 write(u, '(a)') ' Exit Status:'
560 write(u, '(a)') ' Returns 0.'
561 end subroutine help_jobs
562
563 subroutine help_fg(u)
564 integer, intent(in) :: u
565 write(u, '(a)') 'fg: fg [job_spec]'
566 write(u, '(a)') ' Move job to the foreground.'
567 write(u, '(a)') ''
568 write(u, '(a)') ' Place the job identified by JOB_SPEC in the foreground, making it'
569 write(u, '(a)') ' the current job. If JOB_SPEC is not present, the most recent'
570 write(u, '(a)') ' background job is used.'
571 write(u, '(a)') ''
572 write(u, '(a)') ' JOB_SPEC can be:'
573 write(u, '(a)') ' %N Job number N'
574 write(u, '(a)') ' %str Job whose command begins with str'
575 write(u, '(a)') ''
576 write(u, '(a)') ' Exit Status:'
577 write(u, '(a)') ' Returns the status of the command placed in foreground, or 1 if'
578 write(u, '(a)') ' an error occurs.'
579 end subroutine help_fg
580
581 subroutine help_bg(u)
582 integer, intent(in) :: u
583 write(u, '(a)') 'bg: bg [job_spec]'
584 write(u, '(a)') ' Move job to the background.'
585 write(u, '(a)') ''
586 write(u, '(a)') ' Place the job identified by JOB_SPEC in the background, as if it'
587 write(u, '(a)') ' had been started with &. If JOB_SPEC is not present, the most'
588 write(u, '(a)') ' recently suspended job is used.'
589 write(u, '(a)') ''
590 write(u, '(a)') ' Exit Status:'
591 write(u, '(a)') ' Returns 0 unless job control is not enabled or an error occurs.'
592 end subroutine help_bg
593
594 subroutine help_kill(u)
595 integer, intent(in) :: u
596 write(u, '(a)') 'kill: kill [-s sigspec | -signum] pid | jobspec ...'
597 write(u, '(a)') ' Send a signal to a job.'
598 write(u, '(a)') ''
599 write(u, '(a)') ' Send the processes identified by PID or JOBSPEC the signal named'
600 write(u, '(a)') ' by SIGSPEC or SIGNUM. If neither SIGSPEC nor SIGNUM is present,'
601 write(u, '(a)') ' SIGTERM is assumed.'
602 write(u, '(a)') ''
603 write(u, '(a)') ' Options:'
604 write(u, '(a)') ' -s sig SIG is a signal name (e.g., TERM, KILL, HUP)'
605 write(u, '(a)') ' -l List signal names'
606 write(u, '(a)') ' -NUM Send signal number NUM'
607 write(u, '(a)') ''
608 write(u, '(a)') ' Supported signals: HUP (1), INT (2), QUIT (3), KILL (9),'
609 write(u, '(a)') ' TERM (15), STOP (17/19), CONT (18/19), USR1 (10), USR2 (12).'
610 write(u, '(a)') ''
611 write(u, '(a)') ' Exit Status:'
612 write(u, '(a)') ' Returns 0 if at least one signal was sent, 1 on error.'
613 end subroutine help_kill
614
615 subroutine help_wait(u)
616 integer, intent(in) :: u
617 write(u, '(a)') 'wait: wait [-n] [id ...]'
618 write(u, '(a)') ' Wait for job completion and return exit status.'
619 write(u, '(a)') ''
620 write(u, '(a)') ' Wait for each process identified by an ID, which may be a process'
621 write(u, '(a)') ' ID or a job specification, and report its termination status.'
622 write(u, '(a)') ''
623 write(u, '(a)') ' Options:'
624 write(u, '(a)') ' -n Wait for any single job to complete and return its status'
625 write(u, '(a)') ''
626 write(u, '(a)') ' If ID is not given, waits for all currently active child processes.'
627 write(u, '(a)') ''
628 write(u, '(a)') ' Exit Status:'
629 write(u, '(a)') ' Returns the status of the last ID, or 0 if no ID is given, or'
630 write(u, '(a)') ' 127 if ID is not a known process.'
631 end subroutine help_wait
632
633 subroutine help_coproc(u)
634 integer, intent(in) :: u
635 write(u, '(a)') 'coproc: coproc [NAME] command [args]'
636 write(u, '(a)') ' Create a coprocess named NAME.'
637 write(u, '(a)') ''
638 write(u, '(a)') ' Execute COMMAND asynchronously with its standard output and input'
639 write(u, '(a)') ' connected to the shell via a two-way pipe.'
640 write(u, '(a)') ''
641 write(u, '(a)') ' The NAME defaults to COPROC. NAME[0] holds the read fd and'
642 write(u, '(a)') ' NAME[1] holds the write fd. NAME_PID holds the PID.'
643 write(u, '(a)') ''
644 write(u, '(a)') ' Exit Status:'
645 write(u, '(a)') ' Returns 0 on success, 1 if creation fails.'
646 end subroutine help_coproc
647
648 ! --------------------------------------------------------------------------
649 ! Shell Features
650 ! --------------------------------------------------------------------------
651
652 subroutine help_source(u)
653 integer, intent(in) :: u
654 write(u, '(a)') 'source: source filename [arguments]'
655 write(u, '(a)') ' Execute commands from a file in the current shell.'
656 write(u, '(a)') ''
657 write(u, '(a)') ' Read and execute commands from FILENAME in the current shell'
658 write(u, '(a)') ' environment. If FILENAME does not contain a slash, the PATH is'
659 write(u, '(a)') ' searched for it. The return status is the status of the last'
660 write(u, '(a)') ' command executed, or 0 if no commands are executed.'
661 write(u, '(a)') ''
662 write(u, '(a)') ' ARGUMENTS are made available as positional parameters within'
663 write(u, '(a)') ' the sourced file. The original positional parameters are restored'
664 write(u, '(a)') ' when the sourced file completes. Also available as `.`'
665 write(u, '(a)') ''
666 write(u, '(a)') ' Exit Status:'
667 write(u, '(a)') ' Returns the status of the last command executed in FILENAME,'
668 write(u, '(a)') ' or 1 if FILENAME is not found or cannot be read.'
669 end subroutine help_source
670
671 subroutine help_eval(u)
672 integer, intent(in) :: u
673 write(u, '(a)') 'eval: eval [arg ...]'
674 write(u, '(a)') ' Execute arguments as a shell command.'
675 write(u, '(a)') ''
676 write(u, '(a)') ' Combine ARGs into a single string, use the result as input to the'
677 write(u, '(a)') ' shell, and execute the resulting commands.'
678 write(u, '(a)') ''
679 write(u, '(a)') ' Exit Status:'
680 write(u, '(a)') ' Returns the exit status of the executed command, or 0 if no'
681 write(u, '(a)') ' arguments are given.'
682 end subroutine help_eval
683
684 subroutine help_exec(u)
685 integer, intent(in) :: u
686 write(u, '(a)') 'exec: exec [-cl] [-a name] [command [arguments ...]]'
687 write(u, '(a)') ' Replace the shell with the given command.'
688 write(u, '(a)') ''
689 write(u, '(a)') ' Execute COMMAND, replacing this shell with the specified program.'
690 write(u, '(a)') ' If COMMAND is not specified, any redirections take effect in the'
691 write(u, '(a)') ' current shell.'
692 write(u, '(a)') ''
693 write(u, '(a)') ' Options:'
694 write(u, '(a)') ' -c Execute command with an empty environment'
695 write(u, '(a)') ' -l Place a dash at the beginning of the zeroth argument (login)'
696 write(u, '(a)') ' -a name Pass NAME as the zeroth argument to the command'
697 write(u, '(a)') ''
698 write(u, '(a)') ' Exit Status:'
699 write(u, '(a)') ' If command is found and executed, exec does not return. Returns 1'
700 write(u, '(a)') ' if the command is not found, or 126 if found but not executable.'
701 end subroutine help_exec
702
703 subroutine help_command(u)
704 integer, intent(in) :: u
705 write(u, '(a)') 'command: command [-pVv] command [arg ...]'
706 write(u, '(a)') ' Execute a command, bypassing shell functions.'
707 write(u, '(a)') ''
708 write(u, '(a)') ' Runs COMMAND with ARGS suppressing shell function lookup.'
709 write(u, '(a)') ''
710 write(u, '(a)') ' Options:'
711 write(u, '(a)') ' -p Use a default PATH search'
712 write(u, '(a)') ' -v Print a description of COMMAND (short form)'
713 write(u, '(a)') ' -V Print a verbose description of COMMAND'
714 write(u, '(a)') ''
715 write(u, '(a)') ' Exit Status:'
716 write(u, '(a)') ' Returns the exit status of COMMAND, or 127 if not found. With -v/-V,'
717 write(u, '(a)') ' returns 0 if found, 1 if not found.'
718 end subroutine help_command
719
720 subroutine help_type(u)
721 integer, intent(in) :: u
722 write(u, '(a)') 'type: type [-afptP] name [name ...]'
723 write(u, '(a)') ' Display information about command type.'
724 write(u, '(a)') ''
725 write(u, '(a)') ' For each NAME, indicate how it would be interpreted if used as a'
726 write(u, '(a)') ' command name.'
727 write(u, '(a)') ''
728 write(u, '(a)') ' Options:'
729 write(u, '(a)') ' -a Display all locations containing an executable named NAME'
730 write(u, '(a)') ' -p Search only PATH (skip builtins, functions, aliases)'
731 write(u, '(a)') ' -P Same as -p'
732 write(u, '(a)') ' -t Output a single word: alias, keyword, function, builtin, file'
733 write(u, '(a)') ''
734 write(u, '(a)') ' Search order: keywords, aliases, functions, builtins, PATH.'
735 write(u, '(a)') ''
736 write(u, '(a)') ' Exit Status:'
737 write(u, '(a)') ' Returns 0 if all NAMEs are found, 1 if any are not found.'
738 end subroutine help_type
739
740 subroutine help_which(u)
741 integer, intent(in) :: u
742 write(u, '(a)') 'which: which [-as] command [command ...]'
743 write(u, '(a)') ' Locate a command in PATH.'
744 write(u, '(a)') ''
745 write(u, '(a)') ' Search PATH for each COMMAND and print the full path of the first'
746 write(u, '(a)') ' match found. Only searches PATH (does not check builtins,'
747 write(u, '(a)') ' functions, or aliases).'
748 write(u, '(a)') ''
749 write(u, '(a)') ' Options:'
750 write(u, '(a)') ' -a Print all matches in PATH, not just the first'
751 write(u, '(a)') ' -s Silent mode (no output, only set exit status)'
752 write(u, '(a)') ''
753 write(u, '(a)') ' Exit Status:'
754 write(u, '(a)') ' Returns 0 if all commands are found, 1 if any are not found.'
755 end subroutine help_which
756
757 subroutine help_hash(u)
758 integer, intent(in) :: u
759 write(u, '(a)') 'hash: hash [-r] [-d name] [name ...]'
760 write(u, '(a)') ' Remember or display command locations.'
761 write(u, '(a)') ''
762 write(u, '(a)') ' Determine and remember the full pathname of each NAME. If no'
763 write(u, '(a)') ' arguments are given, display information about remembered commands.'
764 write(u, '(a)') ''
765 write(u, '(a)') ' Options:'
766 write(u, '(a)') ' -d name Forget the remembered location of NAME'
767 write(u, '(a)') ' -r Forget all remembered locations'
768 write(u, '(a)') ''
769 write(u, '(a)') ' Exit Status:'
770 write(u, '(a)') ' Returns 0 unless a NAME is not found or an invalid option is given.'
771 end subroutine help_hash
772
773 subroutine help_trap(u)
774 integer, intent(in) :: u
775 write(u, '(a)') 'trap: trap [-lp] [[arg] signal_spec ...]'
776 write(u, '(a)') ' Trap signals and other events.'
777 write(u, '(a)') ''
778 write(u, '(a)') ' Define and activate handlers to be run when the shell receives'
779 write(u, '(a)') ' signals or other conditions.'
780 write(u, '(a)') ''
781 write(u, '(a)') ' Options:'
782 write(u, '(a)') ' -l List signal names and their corresponding numbers'
783 write(u, '(a)') ' -p Display the trap commands associated with each SIGNAL_SPEC'
784 write(u, '(a)') ''
785 write(u, '(a)') ' If ARG is the string ''-'' the signal is reset to its original value.'
786 write(u, '(a)') ' If ARG is the string '''' (empty), the signal is ignored.'
787 write(u, '(a)') ' If ARG is omitted and -p given, display existing trap for signal.'
788 write(u, '(a)') ''
789 write(u, '(a)') ' Pseudo-signals: EXIT (0), ERR, DEBUG, RETURN.'
790 write(u, '(a)') ''
791 write(u, '(a)') ' With no arguments, prints all traps in reusable format.'
792 write(u, '(a)') ''
793 write(u, '(a)') ' Exit Status:'
794 write(u, '(a)') ' Returns 0 unless a SIGSPEC is invalid.'
795 end subroutine help_trap
796
797 subroutine help_history(u)
798 integer, intent(in) :: u
799 write(u, '(a)') 'history: history [-c] [-d offset] [n]'
800 write(u, '(a)') ' Display or manipulate the history list.'
801 write(u, '(a)') ''
802 write(u, '(a)') ' Display the command history with line numbers. HISTORY with an'
803 write(u, '(a)') ' argument of N lists only the last N entries.'
804 write(u, '(a)') ''
805 write(u, '(a)') ' Options:'
806 write(u, '(a)') ' -c Clear the history list'
807 write(u, '(a)') ' -d offset Delete the history entry at position OFFSET'
808 write(u, '(a)') ''
809 write(u, '(a)') ' History entries are stored in the HISTFILE (default ~/.fortsh_history).'
810 write(u, '(a)') ' HISTSIZE controls the maximum number of entries (default 1000).'
811 write(u, '(a)') ''
812 write(u, '(a)') ' Exit Status:'
813 write(u, '(a)') ' Returns 0 unless an invalid option is given.'
814 end subroutine help_history
815
816 subroutine help_fc(u)
817 integer, intent(in) :: u
818 write(u, '(a)') 'fc: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]'
819 write(u, '(a)') ' Display or execute commands from the history list.'
820 write(u, '(a)') ''
821 write(u, '(a)') ' Options:'
822 write(u, '(a)') ' -e ename Select which editor to use. Default is FCEDIT, then'
823 write(u, '(a)') ' EDITOR, then vi'
824 write(u, '(a)') ' -l List lines instead of editing'
825 write(u, '(a)') ' -n Omit line numbers when listing'
826 write(u, '(a)') ' -r Reverse the order of the lines'
827 write(u, '(a)') ' -s Re-execute the command without invoking an editor'
828 write(u, '(a)') ''
829 write(u, '(a)') ' FIRST and LAST select a range of commands. They can be numbers'
830 write(u, '(a)') ' (negative = relative to current) or strings (prefix match).'
831 write(u, '(a)') ''
832 write(u, '(a)') ' With fc -s [old=new], the most recent command starting with'
833 write(u, '(a)') ' COMMAND (or the previous command) is re-executed after substituting'
834 write(u, '(a)') ' OLD with NEW.'
835 write(u, '(a)') ''
836 write(u, '(a)') ' Exit Status:'
837 write(u, '(a)') ' Returns the exit status of the executed command, or 1 on error.'
838 end subroutine help_fc
839
840 subroutine help_alias(u)
841 integer, intent(in) :: u
842 write(u, '(a)') 'alias: alias [name[=value] ...]'
843 write(u, '(a)') ' Define or display aliases.'
844 write(u, '(a)') ''
845 write(u, '(a)') ' Without arguments, prints the list of aliases in reusable form.'
846 write(u, '(a)') ' For each NAME without a value, prints the alias definition.'
847 write(u, '(a)') ' For each NAME=VALUE, defines an alias.'
848 write(u, '(a)') ''
849 write(u, '(a)') ' Exit Status:'
850 write(u, '(a)') ' Returns 0 unless a NAME is not an existing alias.'
851 end subroutine help_alias
852
853 subroutine help_unalias(u)
854 integer, intent(in) :: u
855 write(u, '(a)') 'unalias: unalias [-a] name [name ...]'
856 write(u, '(a)') ' Remove alias definitions.'
857 write(u, '(a)') ''
858 write(u, '(a)') ' Remove each NAME from the list of defined aliases.'
859 write(u, '(a)') ''
860 write(u, '(a)') ' Options:'
861 write(u, '(a)') ' -a Remove all alias definitions'
862 write(u, '(a)') ''
863 write(u, '(a)') ' Exit Status:'
864 write(u, '(a)') ' Returns 0 unless a NAME is not an existing alias.'
865 end subroutine help_unalias
866
867 subroutine help_abbr(u)
868 integer, intent(in) :: u
869 write(u, '(a)') 'abbr: abbr [-es] [name[=value] ...]'
870 write(u, '(a)') ' Manage abbreviations.'
871 write(u, '(a)') ''
872 write(u, '(a)') ' Abbreviations are expanded inline as you type, unlike aliases'
873 write(u, '(a)') ' which are expanded at execution time.'
874 write(u, '(a)') ''
875 write(u, '(a)') ' Options:'
876 write(u, '(a)') ' -e, --erase Erase an abbreviation'
877 write(u, '(a)') ' -s, --show Show all abbreviations'
878 write(u, '(a)') ''
879 write(u, '(a)') ' With no arguments, shows all abbreviations.'
880 write(u, '(a)') ' With name=value, sets an abbreviation.'
881 write(u, '(a)') ' With name only, shows the expansion for that abbreviation.'
882 write(u, '(a)') ''
883 write(u, '(a)') ' Exit Status:'
884 write(u, '(a)') ' Returns 0 on success, 1 if abbreviation not found.'
885 end subroutine help_abbr
886
887 subroutine help_config(u)
888 integer, intent(in) :: u
889 write(u, '(a)') 'config: config [show | create | reload]'
890 write(u, '(a)') ' Manage shell configuration.'
891 write(u, '(a)') ''
892 write(u, '(a)') ' Subcommands:'
893 write(u, '(a)') ' show Display current configuration'
894 write(u, '(a)') ' create Create default configuration file'
895 write(u, '(a)') ' reload Reload configuration from disk'
896 write(u, '(a)') ''
897 write(u, '(a)') ' With no arguments, displays the current configuration.'
898 write(u, '(a)') ''
899 write(u, '(a)') ' Exit Status:'
900 write(u, '(a)') ' Returns 0 on success, 1 on invalid subcommand.'
901 end subroutine help_config
902
903 ! --------------------------------------------------------------------------
904 ! Scripting & Control Flow
905 ! --------------------------------------------------------------------------
906
907 subroutine help_test(u)
908 integer, intent(in) :: u
909 write(u, '(a)') 'test: test [expr]'
910 write(u, '(a)') ' Evaluate conditional expression.'
911 write(u, '(a)') ''
912 write(u, '(a)') ' Exits with a status of 0 (true) or 1 (false) depending on the'
913 write(u, '(a)') ' evaluation of EXPR. Also available as [ expr ].'
914 write(u, '(a)') ''
915 write(u, '(a)') ' File tests:'
916 write(u, '(a)') ' -e FILE Exists -f FILE Regular file'
917 write(u, '(a)') ' -d FILE Directory -L/-h Symbolic link'
918 write(u, '(a)') ' -r FILE Readable -w FILE Writable'
919 write(u, '(a)') ' -x FILE Executable -s FILE Non-empty'
920 write(u, '(a)') ' -b FILE Block device -c FILE Character device'
921 write(u, '(a)') ' -p FILE Named pipe -S FILE Socket'
922 write(u, '(a)') ' -u FILE Setuid -g FILE Setgid'
923 write(u, '(a)') ' -k FILE Sticky bit -O FILE Owned by you'
924 write(u, '(a)') ' -G FILE Owned by your group'
925 write(u, '(a)') ' -v VAR Variable is set'
926 write(u, '(a)') ''
927 write(u, '(a)') ' String tests:'
928 write(u, '(a)') ' -z STR Empty string -n STR Non-empty string'
929 write(u, '(a)') ' S1 = S2 Strings equal S1 != S2 Strings not equal'
930 write(u, '(a)') ' S1 < S2 Lexicographic less S1 > S2 Lexicographic greater'
931 write(u, '(a)') ''
932 write(u, '(a)') ' Arithmetic tests:'
933 write(u, '(a)') ' N1 -eq N2 Equal N1 -ne N2 Not equal'
934 write(u, '(a)') ' N1 -lt N2 Less than N1 -le N2 Less or equal'
935 write(u, '(a)') ' N1 -gt N2 Greater than N1 -ge N2 Greater or equal'
936 write(u, '(a)') ''
937 write(u, '(a)') ' File comparison:'
938 write(u, '(a)') ' F1 -nt F2 Newer than F1 -ot F2 Older than'
939 write(u, '(a)') ' F1 -ef F2 Same file (device and inode)'
940 write(u, '(a)') ''
941 write(u, '(a)') ' Operators: ! (NOT), -a (AND), -o (OR), ( ) grouping.'
942 write(u, '(a)') ''
943 write(u, '(a)') ' Exit Status:'
944 write(u, '(a)') ' Returns 0 if EXPR is true, 1 if false, 2 on syntax error.'
945 end subroutine help_test
946
947 subroutine help_break(u)
948 integer, intent(in) :: u
949 write(u, '(a)') 'break: break [n]'
950 write(u, '(a)') ' Exit for, while, or until loops.'
951 write(u, '(a)') ''
952 write(u, '(a)') ' Exit a FOR, WHILE or UNTIL loop. If N is specified, break N'
953 write(u, '(a)') ' enclosing loops.'
954 write(u, '(a)') ''
955 write(u, '(a)') ' Exit Status:'
956 write(u, '(a)') ' Returns 0 unless N is not greater than or equal to 1.'
957 end subroutine help_break
958
959 subroutine help_continue(u)
960 integer, intent(in) :: u
961 write(u, '(a)') 'continue: continue [n]'
962 write(u, '(a)') ' Resume for, while, or until loops.'
963 write(u, '(a)') ''
964 write(u, '(a)') ' Resume the next iteration of the enclosing FOR, WHILE or UNTIL'
965 write(u, '(a)') ' loop. If N is specified, resume at the Nth enclosing loop.'
966 write(u, '(a)') ''
967 write(u, '(a)') ' Exit Status:'
968 write(u, '(a)') ' Returns 0 unless N is not greater than or equal to 1.'
969 end subroutine help_continue
970
971 subroutine help_return(u)
972 integer, intent(in) :: u
973 write(u, '(a)') 'return: return [n]'
974 write(u, '(a)') ' Return from a shell function.'
975 write(u, '(a)') ''
976 write(u, '(a)') ' Causes a function or sourced script to exit with the return value'
977 write(u, '(a)') ' specified by N. If N is omitted, the return status is that of the'
978 write(u, '(a)') ' last command executed within the function body.'
979 write(u, '(a)') ''
980 write(u, '(a)') ' Exit Status:'
981 write(u, '(a)') ' Returns N, or the last command status if N is not supplied.'
982 write(u, '(a)') ' Returns 2 if called outside a function or sourced script.'
983 end subroutine help_return
984
985 subroutine help_shift(u)
986 integer, intent(in) :: u
987 write(u, '(a)') 'shift: shift [n]'
988 write(u, '(a)') ' Shift positional parameters.'
989 write(u, '(a)') ''
990 write(u, '(a)') ' Rename the positional parameters $N+1,$N+2 ... to $1,$2 ...'
991 write(u, '(a)') ' If N is not given, it is assumed to be 1.'
992 write(u, '(a)') ''
993 write(u, '(a)') ' Exit Status:'
994 write(u, '(a)') ' Returns 0 unless N is negative or greater than $#.'
995 end subroutine help_shift
996
997 subroutine help_getopts(u)
998 integer, intent(in) :: u
999 write(u, '(a)') 'getopts: getopts optstring name [arg ...]'
1000 write(u, '(a)') ' Parse positional parameters.'
1001 write(u, '(a)') ''
1002 write(u, '(a)') ' OPTSTRING contains the option characters to be recognized; if a'
1003 write(u, '(a)') ' character is followed by a colon, the option takes an argument,'
1004 write(u, '(a)') ' which is placed in OPTARG.'
1005 write(u, '(a)') ''
1006 write(u, '(a)') ' Each time getopts is invoked, it places the next option in NAME,'
1007 write(u, '(a)') ' with OPTIND tracking the index of the next argument. OPTIND is'
1008 write(u, '(a)') ' initialized to 1 each time the shell is invoked.'
1009 write(u, '(a)') ''
1010 write(u, '(a)') ' If OPTSTRING begins with '':'', silent error reporting is used.'
1011 write(u, '(a)') ' In this mode, invalid options set NAME to ''?'' with OPTARG set'
1012 write(u, '(a)') ' to the invalid character. Missing arguments set NAME to '':'''
1013 write(u, '(a)') ' with OPTARG set to the option character.'
1014 write(u, '(a)') ''
1015 write(u, '(a)') ' Bundled options like -abc are supported.'
1016 write(u, '(a)') ' If ARGs are given, they are parsed instead of $1, $2, ...'
1017 write(u, '(a)') ''
1018 write(u, '(a)') ' Exit Status:'
1019 write(u, '(a)') ' Returns 0 if an option is found, 1 when end of options is reached.'
1020 end subroutine help_getopts
1021
1022 subroutine help_let(u)
1023 integer, intent(in) :: u
1024 write(u, '(a)') 'let: let arg [arg ...]'
1025 write(u, '(a)') ' Evaluate arithmetic expressions.'
1026 write(u, '(a)') ''
1027 write(u, '(a)') ' Each ARG is an arithmetic expression to be evaluated. If the'
1028 write(u, '(a)') ' last ARG evaluates to 0, let returns 1; otherwise 0.'
1029 write(u, '(a)') ''
1030 write(u, '(a)') ' Exit Status:'
1031 write(u, '(a)') ' Returns 0 if the last expression evaluates to a non-zero value,'
1032 write(u, '(a)') ' 1 if it evaluates to 0.'
1033 end subroutine help_let
1034
1035 subroutine help_exit(u)
1036 integer, intent(in) :: u
1037 write(u, '(a)') 'exit: exit [n]'
1038 write(u, '(a)') ' Exit the shell.'
1039 write(u, '(a)') ''
1040 write(u, '(a)') ' Exits the shell with a status of N. If N is omitted, the exit'
1041 write(u, '(a)') ' status is that of the last command executed.'
1042 write(u, '(a)') ''
1043 write(u, '(a)') ' Before exiting, the EXIT trap is executed and the history file'
1044 write(u, '(a)') ' is saved.'
1045 end subroutine help_exit
1046
1047 ! --------------------------------------------------------------------------
1048 ! System & Completion
1049 ! --------------------------------------------------------------------------
1050
1051 subroutine help_umask(u)
1052 integer, intent(in) :: u
1053 write(u, '(a)') 'umask: umask [-p] [-S] [mode]'
1054 write(u, '(a)') ' Display or set the file mode creation mask.'
1055 write(u, '(a)') ''
1056 write(u, '(a)') ' Sets the file mode creation mask to MODE. If MODE is omitted,'
1057 write(u, '(a)') ' prints the current value of the mask.'
1058 write(u, '(a)') ''
1059 write(u, '(a)') ' Options:'
1060 write(u, '(a)') ' -p Print in a form that may be reused as input'
1061 write(u, '(a)') ' -S Print using symbolic notation (u=rwx,g=rx,o=rx)'
1062 write(u, '(a)') ''
1063 write(u, '(a)') ' MODE is an octal number from 0 to 0777.'
1064 write(u, '(a)') ''
1065 write(u, '(a)') ' Exit Status:'
1066 write(u, '(a)') ' Returns 0 unless MODE is invalid.'
1067 end subroutine help_umask
1068
1069 subroutine help_ulimit(u)
1070 integer, intent(in) :: u
1071 write(u, '(a)') 'ulimit: ulimit [-SHa] [-cdfklmnstuvx [limit]]'
1072 write(u, '(a)') ' Modify shell resource limits.'
1073 write(u, '(a)') ''
1074 write(u, '(a)') ' Provides control over process resource limits.'
1075 write(u, '(a)') ''
1076 write(u, '(a)') ' Options:'
1077 write(u, '(a)') ' -S Use the soft limit (default)'
1078 write(u, '(a)') ' -H Use the hard limit'
1079 write(u, '(a)') ' -a Show all current limits'
1080 write(u, '(a)') ''
1081 write(u, '(a)') ' Resources:'
1082 write(u, '(a)') ' -c Core file size (blocks)'
1083 write(u, '(a)') ' -d Data segment size (kbytes)'
1084 write(u, '(a)') ' -f File size (blocks, default)'
1085 write(u, '(a)') ' -l Max locked memory (kbytes)'
1086 write(u, '(a)') ' -m Max memory size (kbytes)'
1087 write(u, '(a)') ' -n Open files'
1088 write(u, '(a)') ' -s Stack size (kbytes)'
1089 write(u, '(a)') ' -t CPU time (seconds)'
1090 write(u, '(a)') ' -u Max user processes'
1091 write(u, '(a)') ' -v Virtual memory (kbytes)'
1092 write(u, '(a)') ''
1093 write(u, '(a)') ' Use "unlimited" to remove a limit.'
1094 write(u, '(a)') ''
1095 write(u, '(a)') ' Exit Status:'
1096 write(u, '(a)') ' Returns 0 unless an invalid option or error occurs.'
1097 end subroutine help_ulimit
1098
1099 subroutine help_times(u)
1100 integer, intent(in) :: u
1101 write(u, '(a)') 'times: times'
1102 write(u, '(a)') ' Display process times.'
1103 write(u, '(a)') ''
1104 write(u, '(a)') ' Prints the accumulated user and system times for the shell and'
1105 write(u, '(a)') ' for all processes run from the shell.'
1106 write(u, '(a)') ''
1107 write(u, '(a)') ' Output format:'
1108 write(u, '(a)') ' Line 1: Shell user time and system time'
1109 write(u, '(a)') ' Line 2: Children user time and system time'
1110 write(u, '(a)') ''
1111 write(u, '(a)') ' Exit Status:'
1112 write(u, '(a)') ' Returns 0.'
1113 end subroutine help_times
1114
1115 subroutine help_complete(u)
1116 integer, intent(in) :: u
1117 write(u, '(a)') 'complete: complete [-pr] [-A action] [-F func] [-W words] ' // &
1118 '[-o opt] [-P prefix] [-S suffix] [-X pattern] [name ...]'
1119 write(u, '(a)') ' Specify how arguments are to be completed.'
1120 write(u, '(a)') ''
1121 write(u, '(a)') ' For each NAME, specify how arguments are to be completed.'
1122 write(u, '(a)') ''
1123 write(u, '(a)') ' Options:'
1124 write(u, '(a)') ' -r Remove completion specifications for NAMEs'
1125 write(u, '(a)') ' -p Print existing completion specifications'
1126 write(u, '(a)') ' -A action Use ACTION to generate completions'
1127 write(u, '(a)') ' (alias, command, directory, file, function,'
1128 write(u, '(a)') ' hostname, variable, user, group, export, keyword,'
1129 write(u, '(a)') ' builtin, service)'
1130 write(u, '(a)') ' -F func Call FUNC for completions'
1131 write(u, '(a)') ' -W words Split WORDS and generate completions from them'
1132 write(u, '(a)') ' -o opt Completion option (default, dirnames, filenames,'
1133 write(u, '(a)') ' nospace, plusdirs, nosort)'
1134 write(u, '(a)') ' -P prefix Add PREFIX to each completion'
1135 write(u, '(a)') ' -S suffix Add SUFFIX to each completion'
1136 write(u, '(a)') ' -X pattern Exclude completions matching PATTERN'
1137 write(u, '(a)') ''
1138 write(u, '(a)') ' Exit Status:'
1139 write(u, '(a)') ' Returns 0 unless an invalid option is given.'
1140 end subroutine help_complete
1141
1142 subroutine help_compgen(u)
1143 integer, intent(in) :: u
1144 write(u, '(a)') 'compgen: compgen -W wordlist [prefix]'
1145 write(u, '(a)') ' Generate completion matches.'
1146 write(u, '(a)') ''
1147 write(u, '(a)') ' Generate possible completion matches for PREFIX according to the'
1148 write(u, '(a)') ' given options. Matches are printed one per line.'
1149 write(u, '(a)') ''
1150 write(u, '(a)') ' Options:'
1151 write(u, '(a)') ' -W wordlist Use WORDLIST as the source of completions'
1152 write(u, '(a)') ''
1153 write(u, '(a)') ' Exit Status:'
1154 write(u, '(a)') ' Returns 0 if matches are generated, 1 otherwise.'
1155 end subroutine help_compgen
1156
1157 ! --------------------------------------------------------------------------
1158 ! Utilities
1159 ! --------------------------------------------------------------------------
1160
1161 subroutine help_perf(u)
1162 integer, intent(in) :: u
1163 write(u, '(a)') 'perf: perf [on | off | stats | reset]'
1164 write(u, '(a)') ' Performance monitoring.'
1165 write(u, '(a)') ''
1166 write(u, '(a)') ' Control and display shell performance statistics.'
1167 write(u, '(a)') ''
1168 write(u, '(a)') ' Subcommands:'
1169 write(u, '(a)') ' on Enable performance monitoring'
1170 write(u, '(a)') ' off Disable performance monitoring'
1171 write(u, '(a)') ' stats Display detailed performance statistics'
1172 write(u, '(a)') ' reset Reset all performance counters'
1173 write(u, '(a)') ''
1174 write(u, '(a)') ' With no arguments, displays current status and basic stats.'
1175 write(u, '(a)') ''
1176 write(u, '(a)') ' Exit Status:'
1177 write(u, '(a)') ' Returns 0 on success, 1 on invalid subcommand.'
1178 end subroutine help_perf
1179
1180 subroutine help_memory(u)
1181 integer, intent(in) :: u
1182 write(u, '(a)') 'memory: memory [optimize | stats | auto]'
1183 write(u, '(a)') ' Memory pool management.'
1184 write(u, '(a)') ''
1185 write(u, '(a)') ' Display and manage the shell''s internal memory pools.'
1186 write(u, '(a)') ''
1187 write(u, '(a)') ' Subcommands:'
1188 write(u, '(a)') ' optimize Optimize memory pools'
1189 write(u, '(a)') ' stats Display detailed pool statistics'
1190 write(u, '(a)') ' auto Trigger automatic memory optimization'
1191 write(u, '(a)') ''
1192 write(u, '(a)') ' With no arguments, displays memory usage summary including'
1193 write(u, '(a)') ' current/peak allocations and memory used.'
1194 write(u, '(a)') ''
1195 write(u, '(a)') ' Exit Status:'
1196 write(u, '(a)') ' Returns 0 on success, 1 on invalid subcommand.'
1197 end subroutine help_memory
1198
1199 subroutine help_defun(u)
1200 integer, intent(in) :: u
1201 write(u, '(a)') 'defun: defun name "body"'
1202 write(u, '(a)') ' Define a function in one line.'
1203 write(u, '(a)') ''
1204 write(u, '(a)') ' Creates a shell function NAME with the given BODY.'
1205 write(u, '(a)') ' Surrounding quotes are stripped from the body.'
1206 write(u, '(a)') ''
1207 write(u, '(a)') ' Example:'
1208 write(u, '(a)') ' defun greet "echo Hello, $1!"'
1209 write(u, '(a)') ''
1210 write(u, '(a)') ' Exit Status:'
1211 write(u, '(a)') ' Returns 0 on success, 1 on usage error.'
1212 end subroutine help_defun
1213
1214 subroutine help_timeout(u)
1215 integer, intent(in) :: u
1216 write(u, '(a)') 'timeout: timeout DURATION COMMAND [args]'
1217 write(u, '(a)') ' Run a command with a time limit.'
1218 write(u, '(a)') ''
1219 write(u, '(a)') ' Start COMMAND, and kill it if still running after DURATION seconds.'
1220 write(u, '(a)') ''
1221 write(u, '(a)') ' Exit Status:'
1222 write(u, '(a)') ' Returns the exit status of COMMAND, or 1 on error.'
1223 end subroutine help_timeout
1224
1225 subroutine help_help(u)
1226 integer, intent(in) :: u
1227 write(u, '(a)') 'help: help [builtin]'
1228 write(u, '(a)') ' Display information about builtin commands.'
1229 write(u, '(a)') ''
1230 write(u, '(a)') ' Displays brief summaries of builtin commands. If BUILTIN is'
1231 write(u, '(a)') ' specified, gives detailed help for that builtin.'
1232 write(u, '(a)') ''
1233 write(u, '(a)') ' Exit Status:'
1234 write(u, '(a)') ' Returns 0 unless BUILTIN is not a shell builtin.'
1235 end subroutine help_help
1236
1237 subroutine help_true(u)
1238 integer, intent(in) :: u
1239 write(u, '(a)') 'true: true'
1240 write(u, '(a)') ' Return a successful result.'
1241 write(u, '(a)') ''
1242 write(u, '(a)') ' Exit Status:'
1243 write(u, '(a)') ' Always succeeds (returns 0).'
1244 end subroutine help_true
1245
1246 subroutine help_false(u)
1247 integer, intent(in) :: u
1248 write(u, '(a)') 'false: false'
1249 write(u, '(a)') ' Return an unsuccessful result.'
1250 write(u, '(a)') ''
1251 write(u, '(a)') ' Exit Status:'
1252 write(u, '(a)') ' Always fails (returns 1).'
1253 end subroutine help_false
1254
1255 subroutine help_colon(u)
1256 integer, intent(in) :: u
1257 write(u, '(a)') ':: :'
1258 write(u, '(a)') ' Null command.'
1259 write(u, '(a)') ''
1260 write(u, '(a)') ' No effect; the command does nothing. Arguments are expanded'
1261 write(u, '(a)') ' and redirections are performed, but nothing else happens.'
1262 write(u, '(a)') ''
1263 write(u, '(a)') ' Exit Status:'
1264 write(u, '(a)') ' Always succeeds (returns 0).'
1265 end subroutine help_colon
1266
1267 end module builtin_help_texts
1268