.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "SHELLIA" 7 "2020-08-07" "0.1" "shell library" .SH NAME shellia \- library for interactive shell scripts .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 \fB\&. /usr/share/shellia/ia[.interactive|.check|.debug|]\fP .UNINDENT .UNINDENT .SH NAME .sp \fBshellia\fP is a library that allows to run \fBshell\fP scripts interactive. The word interactive is the most characteristic adjective for \fBshellia\fP and the shortest abbreviation found for interactive is \fBia\fP\&. Such a short abbreviation is needed, because most commands brought by \fBshellia\fP start with this short prefix \fBia\fP\&. \fBshellia\fP is composed from \fBshell\fP and \fBia\fP\&. .sp See also \fBPREFIX\fP in shellia(3). .SH DESCRIPTION .sp \fBshellia\fP is a library that allows to run shell scripts silently or interactive and helps to check errors of commands that are combined in \fBsteps\fP\&. .sp This makes it easy to familiarize oneself with a shell script that uses \fBshellia\fP and find unexpected behaviour in the shell script. Also when running the shell script silently \fBshellia\fP can check it \fBstep\fP by \fBstep\fP\&. .sp Shell scripts often become large with many subfunctions, calling many commands. This leads to the following problems, where \fBshellia\fP can help: .INDENT 0.0 .IP \(bu 2 It is not easy to run only parts of the script, to learn about an existing script, to find an error in a script, to change the order of parts of the script for testing or to rerun only a part of the script that failed. .IP \(bu 2 It is not easy to find out, from which part of the script errors, warnings or messages that appear on stdout or stderr are created. And it is often not clear if output of a shell script is ok and can be ignored. .IP \(bu 2 Often commands are started in a shell script without checking for Errors because this would make the scripts too complex. .IP \(bu 2 Many programs can only enable debug at start time. This can result in much debug output, also if only specific debug output is needed. .UNINDENT .sp The shellia library can help with the following features. .INDENT 0.0 .IP \(bu 2 run a script or parts of a script interactively .IP \(bu 2 check each command for unexpected output or returncode .IP \(bu 2 jump to interactive mode if an error occurs or exit the script .IP \(bu 2 helps to structure large scripts .IP \(bu 2 in interactive mode shellia can toggled the debug output level .UNINDENT .SH NOTES .sp When building a \fI\&./script.using.shellia\fP the following hints may be helpful: .SS Do not use a single command as a step .sp It is important to find the right size of a \fBstep\fP to be uses in \fBshellia\fP\&. The idea of a \fBstep\fP is not to check the execution of a single command. Instead a single command can be part of a function, that is called by a \fBstep\fP\&. .SS Input and Output of a step .sp Each \fBstep\fP should be interactively runable by an end user of the script. This means the end user should be able to handle input and output of a \fBstep\fP\&. This often means a \fBstep\fP should not read stdin or send stdout to another \fBstep\fP\&. For example a backup script could have one \fBstep\fP to backup /home and another \fBstep\fP to backup /usr. But a \fBstep\fP that reads data from work disk and another \fBstep\fP that writes backup data to a backup disk should better be combined in a single \fBstep\fP\&. .SS Reasonable size of interactive steps .sp If the user of the script can not imagine what an interactive \fBstep\fP does, this \fBstep\fP may be to detailed and to small. If to many errors may happen in the interactive \fBstep\fP, the \fBstep\fP may be to large. For example, if you need to mount an external disk, this should be a separate interactive \fBstep\fP\&. Because this can give errors, if the disk is not readable. And this errors can again lead to follow up errors. .SS When to use check option \-c and \-C .sp Both options will check the output and the exit code of a \fBstep\fP\&. All output has to be allowed with extended regular expressions in \fBcheck\-mode\fP\&. To be able to control the exit code in the same way, the line \fIexit=\fP (with \fI\fP replace by the exit code), will be added, if the exit code is nonzero. .sp With option \fB\-c\fP, per default every output to \fBstdout\fP and \fBstderr\fP is seen as one output and is displayed as an error. The developer can change this with \fBia_stdout\fP and \fBia_ignore\fP\&. This means with \fB\-c\fP every output is checked, also output that would normally go to \fBstdout\fP\&. This makes it easy to find changed output from a command used, e.g. when upgrading to a new operating system version. .sp With option \fB\-C\fP, per default every output to \fBstdout\fP is unchanged and all output to \fBstderr\fP is seen as an error. The devloper can ignore error output with \fBia_ignore\fP\&. This means the developer has not to handle \fBstdout\fP, which can be good and bad. .sp If a \fBstep\fP calls a programm, that produces \fIstdout\fP and \fIstderr\fP output, and it is most important to retain the order of the output, option \fB\-c\fP should be used. With option \fB\-c\fP the output of both streams would be combined by \fBshellia\fP to one stream. If it is important to know if output is from \fIstdout\fP or from \fIstderr\fP to decide if it is an error, option \fB\-C\fP should be used. .SS Use \-\-quiet, \-\-silent or similar if available .sp If commands are used with check option \fB\-c\fP or \fB\-C\fP, less \fBia_stdout\fP or \fBia_stderr\fP lines have to written, if the commands create less output. .SH EXAMPLE .sp For example imagine a backup script, that writes to an external disk, that should then contain an encrypted and bootable backup. .sp This script may call the following \fBsteps\fP, that are itself functions in the script. .sp The main part of the script could look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX eval \(dq$ia_init\(dq ia_add \(dqopencrypt <\-i>\(dq ia_add \(dqmountbkup <\-i>\(dq ia_add \(dqsynccopy\(dq ia_add \(dqlvcopyvms <\-i> ia_add \(dqfixcrypttab\(dq ia_add \(dqfixfstab\(dq ia_add \(dqprepare_chroot\(dq ia_add \(dqfixinitrd\(dq ia_add \(dqrun_grub\(dq ia_add \(dqclean_chroot\(dq ia_add \(dqumountbkup <\-i>\(dq ia_add \(dqclosecrypt <\-i>\(dq ia \-C .EE .UNINDENT .UNINDENT .SH SEE ALSO .sp shellia(1), shellia(3) .SH AUTHOR bernd.schumacher@hpe.com License: GNU General Public License, version 3 .SH COPYRIGHT Bernd Schumacher (2007-2020) .\" Generated by docutils manpage writer. .