Global API index
Core framework functions index
File: shell-api-core.sh
Global scope
Args - Shell function argument handling
Array - Arrays
Date - Date, time and timers
Env - Shell and Linux Environment
File - File and directories
Float - Floating numbers
Input - User input functions
Int - Integer numbers
Math - Math functions
Str - Strings handling
Term - Terminal settings
Test
test
User - System user-related settings
System devices and low-level file system index
File: shell-api-dev.sh
Adb - ADB-related functions
Dev - System devices and low-level file system settings
Vera - VERA-related functions
Multimedia file manipulation functions index
File: shell-api-multimedia.sh
Image - Image manipulation functions
SVG - SVG manipulation functions
Networking functions index
File: shell-api-net.sh
Net - Networking functions
Packaging functions index
File: shell-api-packing.sh
APT - APT package handling functions
DPKG - dpkg package handling functions
GEM - GEM package handling functions
OPAM - OPAM package handling functions
Pkg - High-level package handling functions
SNAP - SNAP package handling functions
Framework self-test functions index
File: shell-api-selftest.sh
System functions index
File: shell-api-sys.sh
CPU - CPU information functions
Desktop - Desktop settings
gnome - GNOME settings
Screen - Screen settings
XML transformation functions index
File: shell-api-xslt.sh
XSLT - XML Transformations
YAML file handling functions index
File: shell-api-yaml.sh
YAML - YAML file handling functions
API documentation
Core framework functions index
File: shell-api-core.sh
| Function | Documentation | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
_colorprint |
not documented |
||||||||||||||
_colorText <arg1> <arg2> <arg3> |
Print the passed text with the specified color without impacting the current terminal setting (resets to normal) The background color name of the palette shall be specified without the "bg_" prefix
|
||||||||||||||
_setColored <arg1> <arg2> <arg3> |
Updates the passed text by adding the specified fore and background colors The background color name of the palette shall be specified without the "bg_" prefix
|
||||||||||||||
_load <arg1> <arg2> |
Loads another script file by sourcing it (if not loaded yet before). Prior to sourcing, the global var __SHELL_SOURCE_NAME__ is set to hold the basename of the sourced script. __SHELL_SOURCE_NAME__ is restored to previous value after the sourcing.
Returns 1 on error (invalid args), 0 otherwise. |
||||||||||||||
_isLoadDepCached |
Tells whether the cache indicates that the dependency was already loaded |
||||||||||||||
_loadVDep |
Loads a possible dependency bound with a given distro version |
||||||||||||||
_loadDep |
Standard/generic end-user wrapper for dealing with package dependencies. |
||||||||||||||
_loaded <arg1> |
Function to be called by any script API to check whether it has been already sourced or not. When not loaded yet, it defines a global variable which existence means script file had been sourced yet before. Typical use: if _loaded "${BASH_SOURCE[0]}" ; then
return 0
fi
Returns 0 if already loaded, 1 otherwise. |
||||||||||||||
_usage <arg1> |
Standard/generic end-user wrapper for handling usage errors by doing the following:
Optionally displays an error message if second argument is specified
|
||||||||||||||
_susage <arg1> |
Short usage function. Standard/generic end-user wrapper for handling usage errors by doing the following:
Optionally displays an error message if second argument is specified
|
||||||||||||||
_invokeCallback <arg1> |
Invokes safely an application callback, displaying a warning if the callback does not exist.
|
||||||||||||||
_help <arg1> |
Standard/generic end-user wrapper for handling help doc by doing the following:
Optionally displays an error message if second argument is specified
|
||||||||||||||
_optionsN |
This does the same as _options() except that it accepts the additional parameters OPTION_LIST_ARGS_TYPE so that the argument description can reflect the argument types defined. _options() is kept for compatibility. |
||||||||||||||
_options |
Displays script options according to the description list of all options as stored in global variable <APPNAME>__OPTION_LIST_DESC to be passed on as first argument and <APPNAME>__OPTION_LIST_ARGS to be passed on as second argument |
||||||||||||||
_soptions |
Displays a short synopsis of the options according to the description list of all options as stored in global variable <APPNAME>__OPTION_LIST_DESC. |
||||||||||||||
_parseArgs |
Standard/generic end-user wrapper for parsing argument. It handles the -h/--help argument invoking a callback function formatted <appname>__help where <appname> is __SHELL_CURRENT_APPNAME__, ending calling _quit It handles the --man argument invoking a callback function formatted <appname>__man where <appname> is __SHELL_CURRENT_APPNAME__ ending calling _quit |
||||||||||||||
_parseFromArgToVars |
not documented |
||||||||||||||
_parseArgsProcessDashLessArg <arg1> <arg2> <arg3> <arg4> |
Internal callback which performs either of the following depending on the 3rd argument value:
When the 3rd argument is empty, it means the 2nd arg (arg value) is not an option value and the user callback of the same name is called passing on the argument count so far and the argument value (<Appname>___parseArgsProcessDashLessArg). The amount of dashless arguments processed is tracked by a counter passed on by ref.
Returns incremented counter |
||||||||||||||
_quit |
App shell quitting. Ensures a fault-less quitting of the shell (return value 0). User may override default behavior by defining a callback function of the form "<appname>__quit" In absence of user callback, it calls __quit |
||||||||||||||
__quit |
Straight application quitting and bypassing any user-defined quit function. It deactivates the trap for EXIT SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT and calls _exit function. |
||||||||||||||
_exit <arg1> <arg2> |
Exits the shell bailing out with an error message if exit code is not 0. At the end, it calls the _cleanup callback.
|
||||||||||||||
_main |
Standard/generic end-user wrapper for invoking main script function Invokes a callback function formatted <appname>__quit where <appname> is __SHELL_CURRENT_APPNAME__ |
||||||||||||||
_cleanup <arg1> |
Standard/generic end-user wrapper for cleaning up upon signal arising It invokes a callback function formatted <appname>_cleanup, passing on the exit code. Eventually, it calls system exit with the initial caught exit code
|
||||||||||||||
_initShellApi |
Initializes this shell API framework. Following global variables are set:
|
||||||||||||||
_setJobId |
not documented |
||||||||||||||
_initLogVars |
Initializes only the variables related to the message, warning, errors log files, in particular with regard to the log file names and the number of messages:
|
||||||||||||||
_initLogs |
Initializes the log file: message, warning, errors. |
||||||||||||||
_getConfigDir <arg1> |
Returns the path to the existing configuration directory for the currently registered application (__SHELL_CURRENT_APPNAME__), which is defined as <user home dir>/.config/<app name>/.
Returns 0 when a valid configuration folder exists (and was possibly created by this function), otherwise:
|
||||||||||||||
_getRecentListFilePath |
not documented |
||||||||||||||
_readRecentList |
Reads the recent list for the application. The configuration file is expected to be <user home dir>/.config/<app name>/recentlist.yml. The values of the configuration are stored in a map named : <appname in uppercase>__RECENT. The keys are the genuine YAML keys . Example applied for Sumo: for config line " my parameter : my value", there will be value defined as follows <APPNAME>__VARS["my parameter"]="my value" Returns 0 on success, 2 when invalid config dir |
||||||||||||||
__getRecentListFilePath |
not documented |
||||||||||||||
_saveRecentList |
not documented |
||||||||||||||
_lockedFileGetAbsPath |
not documented |
||||||||||||||
_lockedFileRead |
not documented |
||||||||||||||
_lockedFileWrite |
not documented |
||||||||||||||
_getLogDir <arg1> |
Returns the log folder path, ensuring parent dirs are created
|
||||||||||||||
_getLogPath <arg1> |
Returns the user’s log file path, ensuring parent dirs are created If any parameter is specified, the log file is truncated and the __LOG_NB__ is reset to 0
|
||||||||||||||
_getLogWarnPath <arg1> |
Returns the user’s warning log file path, ensuring parent dirs are created If any parameter is specified, the log file is truncated and the __LOG_NB_WARN__ is reset to 0
|
||||||||||||||
_getLogErrPath <arg1> |
Returns the user’s error log file path, ensuring parent dirs are created. If any parameter is specified, the log file is truncated and the __LOG_NB_ERR__ is reset to 0
|
||||||||||||||
_getConfigFilePath |
Returns the user’s local configuration file path. Note this file is not created by this function and may not exist. |
||||||||||||||
_readConfig |
Reads the configuration for the application. The configuration file is expected to be <user home dir>/.config/<app name>/<appname in lowercase>.yml. When this file does not exist, the function <appname>__getDefaultConfigFile is called if the function exists, in order to get the appname’s own default config file path. The values of the configuration are stored in a map named : <appname in uppercase>__VARS. The keys are the YAML keys in upper case where spaces are replaced with "_" Example applied for Sumo: for config line " my parameter : my value", there will be value defined as follows <APPNAME>__VARS["MY_PARAMETER"]="my value" Returns 0 on success, 2 when invalid config dir 3 when invalid config file or failed to read it 4 Sumo-default config does not exist or User-specific config does not exist |
||||||||||||||
_appendConfig |
not documented |
||||||||||||||
_getDependenciesCacheFile |
not documented |
||||||||||||||
_readDependenciesCache |
not documented |
||||||||||||||
_writeDependenciesCache |
not documented |
||||||||||||||
_resetDependenciesCache |
not documented |
||||||||||||||
_foreachLine <arg1> <arg2> <arg3> |
Iterates through the lines
|
||||||||||||||
_foreach <arg1> <arg2> <arg3> |
Iterates through an array and executes the action passed as second argument
|
||||||||||||||
_foreach2 <arg1> <arg2> <arg3> <arg4> |
Same as _foreach, but iterates over 2 arrays which have both the same size
|
||||||||||||||
_foreach3 <arg1> <arg2> <arg3> <arg4> <arg5> |
Same as _foreach, but iterates over 3 arrays which have both the same size
|
||||||||||||||
_debugging |
Tells whether the debug mode is active. |
||||||||||||||
_debug |
Activate or deactivate debug mode. Debug mode is detected as active if variable __LOG_DEBUG__ is defined. It can be activated by this function with the following argument value:
|
||||||||||||||
_log_dbg |
Displays the passed argument string on the standard error output if __LOG_DEBUG__ var. exists. The default behavior can be overriden by a user-defined function of the form <appname>___log_dbg where <appname> the argument passed while sourcing this core shell api. By default, the line is prefixed with [debug]. |
||||||||||||||
_log_err |
Displays the passed argument string on the standard error output and inserts it in the error log file. The default behavior can be overriden by a user-defined function of the form <appname>___log_err where <appname> the argument passed while sourcing this core shell api. By default, the line is prefixed with [error]. |
||||||||||||||
_log_warn |
Displays the passed argument string as a warning on the standard error output and inserts it in the warning log file. The default behavior can be overriden by a user-defined function of the form <appname>___log_warn where <appname> the argument passed while sourcing this core shell api. By default, the line is prefixed with [warning]. |
||||||||||||||
_log_high |
Same as _log(), except it is reserved for messages of higher importance by displaying 'info' with blue background to catch attention |
||||||||||||||
_log |
Displays the passed arguments on the standard output and writes it in the log file if log files were initialized (see initLogs). The default behavior can be overriden by a user-defined function of the form <appname>___log where <appname> the argument passed while sourcing this core shell api. |
||||||||||||||
_log_if |
Same as _log(), but the first argument is boolean telling whether to actually log the passed message. This is useful in application where there’s a switch driven by a configuration parameter |
||||||||||||||
_log_ifnot |
Same as _log(), but the first argument is boolean giving a condition that shall not be met for the loggin |
||||||||||||||
_logf |
Same as _log(), but only writes the log file and no message is displayed on terminal. |
||||||||||||||
_log_array <arg1> |
Displays the passed shell array string on the standard output in the following format: <array key>:<array value for that key> The _log function is used for the display.
|
||||||||||||||
_log_n |
Same as _log, except there is no new line displayed. |
||||||||||||||
_log_status |
not documented |
||||||||||||||
_log_status_end |
not documented |
||||||||||||||
_log_vars_exit |
not documented |
||||||||||||||
_log_vars |
not documented |
||||||||||||||
_log_title |
Same as _log, except that the message is preceeded and followed by an empty line. The default behavior can be overriden by a user-defined function of the form <appname>___log_title where <appname> the argument passed while sourcing this core shell api. |
||||||||||||||
_makeDir |
Creates each component of the specified dir path (mkdir -p) if the dir path does not exit. Redirects errors in the error log files. |
||||||||||||||
_test <arg1> <arg2> <arg3> |
Executes a test
Returns 0 on success, 1 otherwise |
||||||||||||||
_testCase |
Executes the case which ID is specified as argument. When batch execution all tests, the ID will be an increasing number starting from 0. But a random ID can be passed for executing a specific test run via _test. It is up to the _testCase user implementation to handle that ID (which can be a random string). Typically, there would be a case enumeration where the numeric ID and the alternative clear text ID is defined like 0|<my test name>) |
||||||||||||||
_testAll |
Executes all tests by invoking testCase passing as argument an increment ID starting from 0 |
||||||||||||||
Term__setTextMode |
not documented |
||||||||||||||
Term__resetColorData |
not documented |
||||||||||||||
Term__resetColor |
not documented |
||||||||||||||
Term__setColorOn |
not documented |
||||||||||||||
Term__setBgColorOn |
not documented |
||||||||||||||
Term__setColor |
Sets either the foreground or the background color To change the background color, 'true' must be passed as second argument. |
||||||||||||||
Term__buildPalette |
Feed the mal _pal which maps readable colors to the terminal escaped char Readable colors are of the form: [bg_]<color name>[_<text_mode>] If the text mode is not specified , it refers to the default normal text color If 'bg_' is specified, then the color refers to the background color. Otherwise, it is foreground color |
||||||||||||||
Term__showPalette |
not documented |
||||||||||||||
Term__testColors |
not documented |
||||||||||||||
trapDirExits |
Exits if the passed folder does not exist |
||||||||||||||
trapFileExits |
Exits if the passed file does not exist |
||||||||||||||
Env__fn_exists |
Tells whether the function exists and is defined. |
||||||||||||||
Env__distro |
Returns the name and version of the system distribution. Name and version are separated separated by ' ' |
||||||||||||||
Env__distroname |
Returns the name only of the system distribution |
||||||||||||||
Env__distrover <arg1> |
Returns the version only of the system distribution
|
||||||||||||||
Env__arch |
Returns the name of the machine architecture. By default, replaces x86_64 by amd64 |
||||||||||||||
Str__swap |
If called with a single value, this value is assigned to the variable and saves the initial value of the variable in an internal buffer. Afterwards, if the function is called without value, it restores the last saved value for the given variable and forgets about it. Recalling the function does not affect anymore the variable. If called without value and not saved value is available, it has no effect. If called with 2 values, variable is assigned alternatively between the 2 values by successive calls by checking the currently saved value. |
||||||||||||||
Str__randomWord |
not documented |
||||||||||||||
Str__diff <arg1> <arg2> |
Makes a diff between 2 string using the diff systemtool
|
||||||||||||||
Str__getDiffLines <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> |
Performs a 'brutal' line-by-line diff of 2 multiline strings and returns an array containing the lines differences. This function is primarly designed to extract differences between two blocks which are expected to be the same with only few differences.
|
||||||||||||||
Str__isEmpty <arg1> |
Tests a string for emptiness
|
||||||||||||||
Str__spaces <arg1> |
Returns a series of spaces which length is given by first parameter.
|
||||||||||||||
Str__padded <arg1> |
Prints the passed string and appends the number of space padding till to reach the specified fix size. There’s no new line added.
|
||||||||||||||
Str__indent <arg1> <arg2> <arg3> |
Indents a paragraph by inserting spaces at the start of each line.
|
||||||||||||||
Str__prefix <arg1> <arg2> <arg3> |
Prefixes each line of a paragraph with the passed prefix string
|
||||||||||||||
Str__seq <arg1> <arg2> |
Returns a sequence of the same size of length given by first parameter
|
||||||||||||||
Str__len <arg1> |
Prints the length of the passed string
|
||||||||||||||
Str__upcaseFirst <arg1> |
Upcase the first letter of the passed argument string
Returns 0 on success, 1 if wrong arguments |
||||||||||||||
Str__lower <arg1> |
Returns the argument string in lowercase
Returns lowercase string |
||||||||||||||
Str__toLower <arg1> |
Lowercase the passed string by reference. This version should be used instead of lower() when possible since its definition prevents it to be called from a subshell
|
||||||||||||||
Str__upper <arg1> |
Returns the argument string in uppercase
Returns lowercase string |
||||||||||||||
Str__toUpper <arg1> |
Uppercase the passed string by reference. This version should be used instead of upper() when possible since its definition prevents it to be called from a subshell
|
||||||||||||||
Str__startsWith <arg1> <arg2> |
Tells whether the passed string starts with another.
Returns 0: yes, 1:no |
||||||||||||||
Str__endsWith |
not documented |
||||||||||||||
Str__grepAndGetField <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> |
Retrieves the field values of all lines containing a certain substring according to the passed separator and index
|
||||||||||||||
Str__grep <arg1> <arg2> <arg3> |
A simple grep to capture all lines containing a substring
|
||||||||||||||
Str__getField <arg1> <arg2> <arg3> <arg4> <arg5> |
Retrieves the field value in the passed string according to the passed separator and field index.
|
||||||||||||||
Str__contains <arg1> <arg2> |
Tells whether the passed string contains a substring.
Returns 0: yes, 1:no |
||||||||||||||
Str__nbCommonEndString <arg1> <arg2> <arg3> |
Return the string tail in commmon between both given input string, regardless of char case and heading or trailing whitespaces.
|
||||||||||||||
Str__squeeze <arg1> <arg2> <arg3> |
|||||||||||||||
Str__escape <arg1> <arg2> <arg3> <arg4> |
Replaces all the occurrences of the first string parameters trimming leading and trailing occurrences and replacing the rest with the value of the third parameter.
Returns 0 |
||||||||||||||
Str__escapeChar <arg1> <arg2> |
Escapes all the occurrences of the pass char inserting a backslash
Returns 0 |
||||||||||||||
Str__escapeXML <arg1> |
Escapes special XML chars to make them usable as a value in an element. inserting a backslash
Returns 0 |
||||||||||||||
Str__trim <arg1> <arg2> <arg3> <arg4> |
Trims the passed string of the specified char on both of its ends IMPORTANT UPDATE: in#$c is not efficient for big string, because it scans from the end till the beginning till to find a starting 'c' till to find the in="${in#$c}" in="${in%$c}" in%$c is either for the same reasons.
Returns number of trimmed char in all |
||||||||||||||
Str__trimOnce <arg1> <arg2> <arg3> <arg4> |
Same as Str__trim but attempts to remove only 1 occurrence with a very simple implementation. Written for the sake of performance, since the regular variant reveals to be much slower.
Returns number of trimmed char in all |
||||||||||||||
Str__trimStart <arg1> <arg2> <arg3> <arg4> |
|||||||||||||||
Str__skip |
not documented |
||||||||||||||
Str__skipWs |
not documented |
||||||||||||||
Str__trimEnd <arg1> <arg2> <arg3> <arg4> |
|||||||||||||||
Str__last <arg1> <arg2> |
Gets the last char of the passed string and stores it in the second arg passed by reference
@return: char |
||||||||||||||
Str__head <arg1> <arg2> <arg3> |
Prints the first chars till to match the first occurrence of the passed separator, or the last occurrence if any third argument is specified.
Returns the heading substring
|
||||||||||||||
Str__toHead <arg1> <arg2> <arg3> |
Same as Str__head, except that it stores the results in the passed variable
Returns the heading substring
|
||||||||||||||
Str__tail <arg1> <arg2> <arg3> |
Returns the last chars till to match the first occurrence of the passed separator, or the last occurrence if any third argument is specified, when scanning the string reversely.
Returns the tail
|
||||||||||||||
Str__toTail <arg1> <arg2> <arg3> |
Same as Str__tail, except that the results in not echoed on stdout but replaces the value of input variable itself passed as reference
|
||||||||||||||
Str__eraseCommonTail |
not documented |
||||||||||||||
Str__split <arg1> <arg2> <arg3> <arg4> <arg5> |
Split the passed string in two parts according to the passed separator. The first occurrence of the separator from the left is considered.
Returns 0 if the string could be split into 2 parts, false (1) otherwise (namely no separator found) |
||||||||||||||
Str__replace <arg1> <arg2> <arg3> |
Replaces all occurences of a certain string with another. Modifies the input string
Returns updated input string |
||||||||||||||
Str__replaceOne <arg1> <arg2> <arg3> |
Replaces only 1 occurence of a certain string with another. Modifies the input string
Returns updated input string |
||||||||||||||
Str__substringCount <arg1> <arg2> |
Counts the number of occurences of a certain substring
Returns 0 |
||||||||||||||
Str__lineCount <arg1> <arg2> |
Returns the number of lines of the specified string
|
||||||||||||||
Str__linesToArray <arg1> <arg2> |
Retrieves the lines contained in a string and stores them into the passed array
|
||||||||||||||
Str__shrinkToRight <arg1> <arg2> <arg3> |
If the passed string size exceeds a maximum size (maxlen) , it is truncated at right and truncated part is replaced with a replacement string
|
||||||||||||||
Str__shrinkToMid <arg1> <arg2> <arg3> |
Shrinks the passed string to a string of a maximum size (maxlen) given in second argument. The string is shrinked that both ends of the string is limited to maxlen/2, the remaining being replaced with the specified replacement string.
|
||||||||||||||
Str__fitToLineWidth <arg1> <arg2> |
Rearranges a multiline text so that each line does not exceed the specified width as argument, by splitting the line as many times as necessary. During the process, the original linefeeds are preserved.
|
||||||||||||||
Str__justify <arg1> <arg2> |
Rearranges a multiline text so that each line is forced to have the specified width by duplicating spaces as much as necessary.
|
||||||||||||||
Str__toCharArray <arg1> <arg2> |
Converts a string to a char array, storing in the passed variable all chars as an array.
|
||||||||||||||
Str__toAsciiDocId |
Str__toAsciiDocId |
||||||||||||||
Str__isWord |
Indicates whether the passed argument is a word, than means a random sequence of chars from a to z (lowercase or uppercase) -, _ or . |
||||||||||||||
Str__highlight <arg1> <arg2> <arg3> <arg4> <arg5> |
Highlight substrings in input string matching any of the passed keywords
|
||||||||||||||
Int__isInt |
not documented |
||||||||||||||
Int__Int |
not documented |
||||||||||||||
Int__Int_r |
not documented |
||||||||||||||
Int__percentage |
not documented |
||||||||||||||
Int__calc |
not documented |
||||||||||||||
Int__calc_r |
not documented |
||||||||||||||
Int__withinRange |
not documented |
||||||||||||||
Int__series |
not documented |
||||||||||||||
Int__min <arg1> <arg2> <arg3> |
Returns the minimum of the two passed integers
|
||||||||||||||
Int__max <arg1> <arg2> <arg3> |
Returns the maximum of the two passed integers
|
||||||||||||||
Int__readVersion <arg1> <arg2> <arg3> |
Retrieves version numbers from a string of the form 'x[[.y].z]' If a component is not define, there’s an empty string
|
||||||||||||||
Int__getIntTrail |
not documented |
||||||||||||||
Float__compare |
not documented |
||||||||||||||
Float__calc |
not documented |
||||||||||||||
Math__byteSize2ReadableSize |
not documented |
||||||||||||||
Math__kbyteSize2ReadableSize |
not documented |
||||||||||||||
Math__size2ReadableSize <arg1> |
|
||||||||||||||
Math__convertSizeToMiB <arg1> <arg2> |
|
||||||||||||||
Args__checkCount <arg1> <arg2> <arg3> <arg4> |
This function can be conveniently used to check the number of arguments passed to a called function
Returns 0 when the args counts are matching, 1 otherwise. It is up to the calling function to determine whether it can go on its execution or interrupt |
||||||||||||||
Args__checkMinCount <arg1> <arg2> <arg3> <arg4> |
This function can be conveniently used to check the minimum required number of arguments passed to a called function
Returns 0 when the args counts are matching, 1 otherwise. It is up to the calling function to determine whether it can go on its execution or interrupt |
||||||||||||||
Array__print <arg1> <arg2> |
Prints the values
|
||||||||||||||
Array__concat <arg1> <arg2> |
Concatenates 2 arrays
|
||||||||||||||
Array__getSortedArray <arg1> <arg2> |
Sorts an array of spaceless values. Note this does not work if an value contains any space, because this output array is rebuilt from a sorted string
Returns 0 when found, 1 when not |
||||||||||||||
Array__contains <arg1> <arg2> |
Tells whether an array contains a string equal to the passed value
Returns 0 when found, 1 when not |
||||||||||||||
Array__contains_by_string <arg1> <arg2> |
Same as Array__contains, except that the array is past in the form of a string where items are separated with a space. The function reconstructs a builtin array from the string.
Returns 0 when found, 1 when not |
||||||||||||||
Array__fromString <arg1> <arg2> <arg3> <arg4> <arg5> |
Creates an array from a string, in which fields are separated by the specified separator. Spaces are trimmed from each field Update: this replaces Array__fromStringOLD, because it is possible to detect chars escaped with \, whereby the separator can be contained itself in a value. It is also more efficient.
|
||||||||||||||
Array__fromStringOLD <arg1> <arg2> <arg3> |
Creates an array from a string, in which fields are separated by the specified separator. Spaces are trimmed from each field
|
||||||||||||||
Array__toString <arg1> <arg2> <arg3> |
Converts an array to a string , separating items by the supplied separator
|
||||||||||||||
Array__toTextTable <arg1> <arg2> <arg3> <arg4> |
Converts a table of records to a terminal output sheet where the data of each line is displayed in a column on equal size, which is set to the data field of maximum size A record is a lines containing data fields which are separated by the specified separator as arg 2. When no separator is specified, ';' is assumed, i.e. CSV records format is assumed Option third parameter enables to pass an alternate table of records to use explicitly for the computing of the column width. A typical use is when the input string containing escape chars for terminal colors, whereby the length of the internal string won’t match that on the display. Typically, the 3rd argument would be the copy of the 1st argument, but without the terminal escape chars.
|
||||||||||||||
Input__getForcedInput |
not documented |
||||||||||||||
Input__pushForcedInput |
Push on the stack a forced input, i.e. a predefined answer for any Input__ function |
||||||||||||||
Input__testYesForcedInput |
not documented |
||||||||||||||
Input__testForcedInput |
not documented |
||||||||||||||
Input__popForcedInput |
Removes a forced input from the head of the stack.
|
||||||||||||||
Input__clearForcedInput |
not documented |
||||||||||||||
Input__pressToContinue |
not documented |
||||||||||||||
Input__timeoutKeystroke |
not documented |
||||||||||||||
Input__password <arg1> |
Prompts for a password
|
||||||||||||||
Input__confirm_high |
Performs the exact same as Input__confirm, but prefixes the question sentence with 'Question' on yellow background. |
||||||||||||||
Input__confirm <arg1> <arg2> <arg3> |
Prompts for a confirmation among the following : y,Y,n,yes,YES,no,NO Default prompt 'y/n' is automatically appended to the question by default.
Returns 0 upon positive confirmation, 1 otherwise Question is asked until a valid answer is given. |
||||||||||||||
Input__memsize <arg1> <arg2> <arg3> <arg4> |
Prompts for a memory size among the following : xG, xM, xK respectively x Gibibytes (GiB), x Mebibytes (MiB), x kibibytes (KiB) Default prompt 'int followed by G/M/K or a to abort' is automatically appended to the question by default. Question is asked until a valid answer is given except if param 4 is specified
Returns 0 upon positive entry, |
||||||||||||||
Input__dirpath <arg1> <arg2> <arg3> <arg4> |
Prompts for a file system path. Question is asked until a valid answer is given.
Returns 0 upon positive entry, |
||||||||||||||
Input__sentence |
not documented |
||||||||||||||
Input__Word <arg1> <arg2> <arg3> <arg4> |
Prompts for a word, i.e. a sequence of alphanumeric letter plus other chars like _,- and . Question is asked until a valid answer is given.
Returns 0 upon positive entry, |
||||||||||||||
Input__cursorSelect |
not documented |
||||||||||||||
Input__cursorSelect_manageIgnoreIndex <arg1> <arg2> <arg3> |
This function is intended to be called after an update of the current index, to determine whether the new index is pointing to an index to be ignored. Depending on the previous navigation action (up or downwards the list), the current index is corrected to avoid an ignore index and shifted resp. one step up or down in the list. NOTE: It does not not yet handle the case of successive ignored lines, for which it may have to be called recursively
|
||||||||||||||
Input__cursorSelec…eIndexOnCurrentPage <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> |
This function is intended to be called before a page jump to determine whether there’s an ignore ahead when jumping forward (down) or one before current index when jumping backward (up). If so
|
||||||||||||||
File__basename <arg1> <arg2> |
Returns the base file name (with its extension) of the passed file name
|
||||||||||||||
File__dirname <arg1> <arg2> |
Returns the dirname of the passed file path. The path is assumed to be an absolute path without . or .. components.
|
||||||||||||||
File__corename <arg1> <arg2> |
Returns the core file name (without its extension) of the passed file name
|
||||||||||||||
File__ext |
Returns the file extension of the passed file name |
||||||||||||||
File__noext |
Returns the file path with extension |
||||||||||||||
File__realpath <arg1> <arg2> <arg3> <arg4> |
Returns the realpath of a file
|
||||||||||||||
File__cwd |
not documented |
||||||||||||||
File__dirExists |
not documented |
||||||||||||||
File__exists |
not documented |
||||||||||||||
File__fileExists |
not documented |
||||||||||||||
File__linkExists |
not documented |
||||||||||||||
File__getSize <arg1> <arg2> |
Return the size of the passed file or directory in bytes
|
||||||||||||||
File__dirSHA256 <arg1> <arg2> <arg3> <arg4> |
Computes a signature for a directory based on the ls -gRA command ensuring a consistent and deterministic ls content on any machine regardless of:
|
||||||||||||||
File__lsSignature <arg1> |
Returns a universal, consistent and deterministic 'ls' signature for the specified file or folder across any system, regardless of :
The format is the following: <UTC timestamp> <size in bytes> <permissions/file mode bits> <number of hardlinks> <quoted path>
Returns echoes the signature and standard output |
||||||||||||||
File__createSubdirs <arg1> |
Creates in the current working directory subdirectories which names are given as array to this function
|
||||||||||||||
File__createTempDir <arg1> |
Creates a temporary folder in default system /tmp folder and inserts it in the global map for subsequent cleanup
|
||||||||||||||
File__deleteTempDir <arg1> |
Deletes the temporary folder passed as argument. If it was created with File__createTempDir, it also clears the matching entry in the global map. This function adds a level of safety by checking that the argument really starts with /tmp
|
||||||||||||||
File__deleteAllTempDirs <arg1> |
Deletes all temporary folders created with File__createTempDir
|
||||||||||||||
File__createTempFile <arg1> <arg2> |
Creates a temporary file in default system /tmp folder and inserts it in the global map for subsequent cleanup
|
||||||||||||||
File__deleteTempFile <arg1> |
Deletes the temporary file passed as argument. If it was created with File__createTempFile, it also clears the matching entry in the global map. This function adds a level of safety by checking that the argument really starts with /tmp
|
||||||||||||||
File__deleteAllTempFiles <arg1> |
Deletes all temporary files created with File__createTempFile
|
||||||||||||||
File__deleteAllTempItems <arg1> |
Deletes all temporary files created with File__createTempFile
|
||||||||||||||
File__copyDirs <arg1> <arg2> <arg3> |
Performs a mirror copy of folders contained within the passed source folder path to the specified target folder. The operation uses the function File__mirrorCopy.
|
||||||||||||||
File__mirrorCopy <arg1> <arg2> <arg3> |
Performs a mirror of a file/folder The operation is based on the rsync command, whose output on standard output is filtered. This function is useful when it is itself used from another script.
Returns 0 only upon success |
||||||||||||||
File__readYAMLLikeFile <arg1> <arg2> |
Reads a YAML-like file consisting of a list of pairs 'property name : propery value' on each like. This is not a YAML parser, it is just a basic reader for simple configuration without having to depend on other tools.
whereby keys are the prop names and values the prop values The map must be declare wit "declare A" Returns 0 on success, 1 when not existing or not a regular file, 2 when invalid syntax. On error 2, the prop map may already contain the values which could be read till that point. |
||||||||||||||
File__readYAMLLikeLine |
not documented |
||||||||||||||
File__writeJobProgressFile |
not documented |
||||||||||||||
File__setProgressFileTotalSteps |
not documented |
||||||||||||||
File___writeJobProgressFile |
not documented |
||||||||||||||
File__createFromZTemplate <arg1> <arg2> <arg3> |
Creates a new file from a "Z" template, i.e. a template text file which contains keywords of the form '%<keyword id>%' which are replaced by associated values pass as parameters to this function
|
||||||||||||||
File__list <arg1> <arg2> |
Lists the files of the passed folder path and stores their basename in the passed array var ref
|
||||||||||||||
File__foreach <arg1> <arg2> |
Iterates through the files contained in the passed directory and and executes the action passed as second argument
|
||||||||||||||
File__append <arg1> <arg2> |
Appends some content to a file. Uses the printf function. Third parameter tells whether to add a new line (true by default).
|
||||||||||||||
Date__readYMD <arg1> <arg2> <arg3> <arg4> |
Given a string of the form yy-mm-dd hh:mm:ss, extract the year, month and day items and stores it into the passed var refs.
|
||||||||||||||
Date__readYMD2 |
not documented |
||||||||||||||
Date__isLessOrEqualThan <arg1> <arg2> <arg3> <arg4> |
Given a date string of the form yy-mm-dd hh:mm:ss, tells this date is earlier than the supplied YMD date components.
Returns 0 if less, 1 otherwise |
||||||||||||||
Date__timestamp |
not documented |
||||||||||||||
Date__startTimer |
not documented |
||||||||||||||
Date__elapsedSecondsTimer |
not documented |
||||||||||||||
Date__elapsedMinutesTimer |
not documented |
||||||||||||||
Date__getTimezone <arg1> |
Returns the active timezone. First attempts to read it from TZ env variables. When not attempts to read it using timedatectl
|
||||||||||||||
User__getFullUserName |
not documented |
||||||||||||||
Term__countdown <arg1> |
Implements a simple countdown
|
||||||||||||||
Term__resize <arg1> <arg2> |
Resizes the terminal the number of lines and columns as specified in the arguments. Basically, this is a wrapper for the 'resize' commmand, which standard output is masked.
Returns the return value of the bash 'resize' command |
||||||||||||||
Term__rows |
not documented |
||||||||||||||
Term__cols |
not documented |
||||||||||||||
Term__resizeMinimum <arg1> <arg2> |
Ensures that the terminal has at a minimum the size as specified in the arguments. If the current terminal is large enough, its size is not modified.
Returns the return value of the bash 'resize' command |
||||||||||||||
Term__updateLine <arg1> |
Prints a string on standard output by overwriting last printed line. A carriage return is done and line till the end is cleared prior to printing value
|
||||||||||||||
Term__updateProgressBar <arg1> <arg2> <arg3> |
This enables to show and update a text-based progress bar on the terminal. The bar is of the form, e.g. : |===== | 25% The bar is displayed the first time that the function is called according to a maximum step value and a number of incrementation achieved steps. The masking of the cursor is activated when this function is called. It is up to the calling script to restore the terminal settings (e.g. by using Term__reset) when the progress bar is not used anymore.
E.g. assuming a max step of 100, calling 4 times this function with 25 achieved steps results in a 100% completion. Returns 0 when 100% is reached, 1 otherwise. |
||||||||||||||
Term__clear |
not documented |
||||||||||||||
Term__maskCursor |
Make the cursor invisible and disable echoing. |
||||||||||||||
Term__restoreCursor |
Reverse operation of cursor masking, it ensures the cursor is visible and key echoing is enabled. |
||||||||||||||
Term__eatReturns |
not documented |
||||||||||||||
Term__enterPrivateBufferMode |
Enter the private buffer mode, whereby the existing scrollback can be saved and restored afterwards when either Term__exitPrivateBufferMode or Term__reset is called. |
||||||||||||||
Term__exitPrivateBufferMode |
Exits the private buffer mode. |
||||||||||||||
Term__reset |
Resets the terminal by enforcing cursor visibility and echoing and exiting of private buffer mode. |
||||||||||||||
Term__cursorMoveLeft <arg1> |
Moves the cursor to the left for the amount of specified chars
|
||||||||||||||
Term__moveTo |
not documented |
||||||||||||||
Term__moveCursorUp |
not documented |
||||||||||||||
Term__moveCursorDown |
not documented |
||||||||||||||
Term__eraseLinesUp |
not documented |
||||||||||||||
Term__eraseLines <arg1> <arg2> |
Erase the amount of terminal lines as specified by first argument starting from the current line. The cursor pos is reset to the line start of the current line before call of this function.
|
||||||||||||||
Term__eraseCurrentLine |
Erase the current terminal line and pushes back the cursor to the line start. |
||||||||||||||
Term__eraseCurrent…umpCursorToNextLine |
Erase the current terminal line and pushes back the cursor to the line start. |
||||||||||||||
Term__printBanner <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> <arg7> |
Prints banner frame which fits with the content of the message. There are various parameters to control aspect of the frame. Special lines are interpreted:
@example: With text=" <hr> Backup of AppData (Application Data) of distant Windows system Please check system is running and reachable over network ! " Term__printBanner "\$text" "|" " " "-" 1 results in: ________________________________________________________________ | | disk |---------------------------------------------------------------- | | Backup of AppData (Application Data) of distant Windows system | | Please check system is running and reachable over network ! |________________________________________________________________ |
||||||||||||||
Term__resolveMaxColumnsWidth <arg1> <arg2> |
Provided a table which rows are given as lines and cells are given as space-separated values in each rows, this function computes the maximum number of chars that occupies each column. To operation, this function relies on function Term__printTableRow, whereby the second and third parameters are used specifically for that purpose.
Returns an array giving the maximum number of chars occupied by each column. E.g "10 6 20" for a 3-column table
|
||||||||||||||
Term___printTableRow |
This function is called internally by Term__printTableRow. See related documentation. |
||||||||||||||
Term__printTableRow <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> |
Provided a table which rows are given as lines and cells are given as space-separated values in each rows, this function displays the table with fixed size columns given by second parameter as a list of char length for each column. By using Term__resolveMaxColumnsWidth prior to this function, one can compute the exact width of each column to match the largest string value which can be found in that column. The actual function which is achieving the display is Term___printTableRow (with 3 underscores). This wrapper function is in charge of setting the line formatting (e.g. color) according to the line header which is ended by '§§'.
|
||||||||||||||
test__perf |
Examples of usage: test__perf 5000 'var=$(dirname ${BASH_SOURCE[0]})'
#test__perf 5000 'var=${BASH_SOURCE[0]%/*}'
#test__perf 5000 'GENAPP__VARS["MYDIR"]="$(readlink -f "${Genapp__sourcedirname}")"'
test__perf 5000 'read Genapp__sourcedirname< <(readlink -f "${Genapp__sourcedirname}")'
|
||||||||||||||
Test__assertFilesShouldNotExist <arg1> |
Checks that the list of passed regular file paths are not valid (do NOT exist). Exits the current shell script (_exit -1 is called) when at least one file exists.
|
||||||||||||||
Test__assertFilesShouldExist <arg1> |
Checks that the list of passed regular file paths are valid (exist). Otherwise, exits the current shell script (_exit -1 is called) when at least one file does not exist.
|
||||||||||||||
Test__assertDirsShouldExist <arg1> |
Checks that the list of passed directory paths are valid (exist). Otherwise, exits the current shell script (_exit -1 is called) when at least one folder does not exist.
|
||||||||||||||
Test__assertFileLastLine <arg1> <arg2> |
Checks whether the last line of the passed file corresponds exactly to the string passed as second argument. Thus, char case is relevant. Exits the current shell script (_exit -1 is called) when the file does not exist or line was not found.
|
||||||||||||||
Test__assertFileLine <arg1> <arg2> <arg3> |
Checks whether the line of the specified line number of the passed file corresponds exactly to the string passed as third argument. Thus, char case is relevant. Exits the current shell script (_exit -1 is called) when the file does not exist or line was not found.
|
||||||||||||||
Test__assertFileContent <arg1> <arg2> |
Checks whether the content of the passed file matches exactly the string passed as second argument. Thus, char case is relevant. Exits the current shell script (_exit -1 is called) when the file does not exist or the content does mismatch
|
||||||||||||||
Test__assertFileContentPattern <arg1> <arg2> |
Checks whether the content of the passed file matches the specified string pattern as second argument. Pattern is like those passed to the bash’s [[ ]] test operator. Exits the current shell script (_exit -1 is called) when the file does not exist or the content does not match the pattern
|
||||||||||||||
Test__assertFileContainsLine <arg1> <arg2> |
Checks whether the passed file contains a line corresponding exactly to the string passed as second argument, thus char case is relevant. Exits the current shell script (_exit -1 is called) when the file does not exist or line was not found.
|
||||||||||||||
Test__assertSameFiles <arg1> <arg2> <arg3> |
Test whether 2 files have exactly the same content. 'diff' tool is used for the test. On failure, exits the current shell script (_exit -1 is called)
|
||||||||||||||
Test__assertChangeDir <arg1> |
Changes the current working directory to the passed one. On failure, exits the current shell script (_exit -1 is called)
|
||||||||||||||
Test__assertChangeToNewDir <arg1> |
Same as Test__assertChangeDir, except that it creates the directory when it does not exist. On failure to cd or create the folder, exits the current shell script (_exit -1 is called)
|
||||||||||||||
Test__assertCleanupDir <arg1> |
Removes the passed directory and all its content recursively. Exits the current shell script (_exit -1 is called) if the folder does not exist or the removal failed.
|
||||||||||||||
Test__assertCmdExit <arg1> <arg2> |
This checks the exit code of the passed command execution against the passed reference value Exits the current shell script (_exit -1 is called) upon mismatch
|
||||||||||||||
Test__assertCmdNotExit <arg1> <arg2> |
This checks the exit code of the passed command execution is different of the passed reference value Exits the current shell script (_exit -1 is called) when the exit code does match
|
||||||||||||||
Test__assertCmd <arg1> <arg2> |
This checks the first output line resulting from passed command execution. Exits the current shell script (_exit -1 is called) when there’s a mismatch.
|
||||||||||||||
Test__assertCmdOutput <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> |
This checks that the output of command matches that of a reference file content. 3rd parameter tells whether to ignore whitespaces at the beginning and end of each content lines to compare Optionally, start and end line numbers can be specified. Optionally, an additional space-separated line numbers to be ignored can be specified.
|
||||||||||||||
Test__assertCmdOutput_handleLineDiffs |
not documented |
||||||||||||||
Test__assertSymlinkPath <arg1> <arg2> |
Tests whether a symbolic link points to the specified absolute path On failure, exits the current shell script (_exit -1 is called)
|
||||||||||||||
Test__assertTwoCommandsSameOutput |
This checks the output of one command is the same of another command Exits the current shell script (_exit -1 is called) when there’s a mismatch. |
Networking functions index
File: shell-api-net.sh
| Function | Documentation | ||||
|---|---|---|---|---|---|
Net__checkOpenPort <arg1> <arg2> |
Tests whether a given port is open on a given host on the network using nmap
|
||||
Net__isHTTP <arg1> |
Tells whether the passed argument looks like an HTTM URL, i.e. of the basic form [http[s]://]xxx(.yyy)+ Safe characters: Alphanumeric [0-9a-zA-Z], special characters $-_.+!*'(), No Reserved characters which are not allowed: / ? : @ = &
Returns 0 when valid URL, false (1) when not, <0 on arg error |
||||
Net__decodeHTTP <arg1> <arg2> |
Extracts only the host address from the HTTP URL
|
||||
Net__isURL <arg1> |
Tells whether the passed argument looks like an URL, i.e. of the basic form xxxxx://yyyyy
Returns 0 when valid URL, false (1) when not |
||||
Net__isIP <arg1> |
Tells whether the passed argument looks like an IP4 address, i.e. of the basic form <number>.<number>.<number>.<number>
Returns 0 when valid IP, false (1) when not, <0 on arg error |
||||
Net__isUNC <arg1> |
Tells whether the passed argument looks like a UNC path (universal naming convention) of the basic form //server/sharename[/path]
Returns 0 when valid UNC, false (1) when not, <0 on arg error |
||||
Net__decodeUNC <arg1> |
Extracts hostname/ip, share from passed UNC Example of valid netlogin: //192.168.0.40/MyShareName
|
||||
Net__isLogin <arg1> |
Tells whether the passed argument looks like a login path of the basic form userlogin@host
|
||||
Net__decodeLogin <arg1> |
Extracts hostname/ip and user from passed netlogin <user>@<host>[:path] examples of valid netlogin:
|
||||
Net__isFTPURL <arg1> |
Tells whether the passed argument looks like a FTP URL, i.e. of the basic form ftp://[user@]host
|
||||
Net__decodeFTPURL |
not documented |
||||
Net__isNFSURL <arg1> |
Tells whether the passed argument looks like an NFS URL, i.e. of the basic form nfs://host:share
|
||||
Net__isNFS <arg1> |
Tells whether the passed argument looks like a regular NFS device, i.e. of the basic form host:share
|
||||
Net__decodeNFSURL |
not documented |
||||
Net__isSSHURL <arg1> |
Tells whether the passed argument looks like a SSH URL, i.e. of the basic form ssh://[user@]host[:port][/path]
|
||||
Net__decodeSSHURL |
not documented |
||||
Net__isSMBURL <arg1> |
Tells whether the passed argument looks like a SMB URL, i.e. of the basic form smb://yyyyy
|
||||
Net__decodeSMBURL <arg1> |
Extracts hostname/ip, user and share (shared folder name) from the passed URL. Expected URL format is the following: smb://<hostname or IP>[/<user>[:password][/<share>]] Examples of valid URL:
|
||||
Net__getHostIP |
not documented |
||||
Net__getLocalHostIP |
not documented |
||||
Net__getLocalHostname |
not documented |
||||
Net__getHostname <arg1> <arg2> |
Retrieves the hostname from the passed IP. This function executes 2 subshells , one for nsloopkup, another for awk.
|
||||
Net__IP2Name <arg1> <arg2> |
Converts an IP to the matching hostname
|
||||
Net__resolve |
not documented |
||||
Net__getDeviceName |
Retrieves the name of the network device |
||||
Net__getDeviceMAC <arg1> <arg2> |
Retrieves the MAC address bound with the network device passwed as argument
|
||||
Net__getMAC <arg1> |
Retrieves the MAC address bound with the device used for default routing
|
||||
Net__MAC |
Same as Net__getMAC, except that it echoes the MAC instead of assigning a variable passed as argument |
||||
Net__download <arg1> |
Download a file from a given URL using wget
Returns 0 on success, 2 if site is not reachable, 1 if site is reachable but download failed somehow. |
||||
Net__isCloudDevice |
Tells whether the passed argument string is a valid known cloud service driver (not an URL). e.g. google-drive-ocamlfuse |
||||
Net__getCloudURLFromDevice |
not documented |
||||
Net__isNetworkURL |
not documented |
System devices and low-level file system index
File: shell-api-dev.sh
| Function | Documentation | ||||||
|---|---|---|---|---|---|---|---|
Dev_getPartUUID |
not documented |
||||||
Dev_getPartNames |
not documented |
||||||
Dev_getPartNamesReduced |
not documented |
||||||
Dev__initPartTypes |
not documented |
||||||
Dev__initfstype2PartUUIDTable |
not documented |
||||||
Dev__isBlockDevice |
not documented |
||||||
Dev__isRegularFile |
not documented |
||||||
Dev__getFileType |
not documented |
||||||
Dev__getBlockDeviceParent <arg1> |
Retrieves and prints on stdout the block device size
Returns 0 |
||||||
Dev__blockDeviceSize <arg1> |
Retrieves and prints on stdout the block device size
Returns 0 |
||||||
Dev__getBlockDeviceLabel <arg1> <arg2> |
Retrieves the block device label
Returns return value of lsblk command executed |
||||||
Dev__findMount <arg1> <arg2> <arg3> |
Retrieves the source and mount point from an argument which is either the source or the mount point. This function relies on 'mount' command which prevents it from blocking in case of broken connections.
|
||||||
Dev__findMountSource <arg1> <arg2> |
Retrieves the source of a mounted folder. If a network connection is broken, the findmnt command may block. As alternative, use findMount above.
|
||||||
Dev__findMountPoint <arg1> <arg2> |
Retrieves the mounted folder from a source device
|
||||||
Dev__findMountPointOptions <arg1> <arg2> |
Retrieves the options from a source device
|
||||||
Dev__getDeviceInfo <arg1> <arg2> |
Retrieves a device specific info with udevadm tool
Returns 0 if the requested data was found, 1 otherwise and the output data is set to "-" |
||||||
Dev__isBootable <arg1> |
Tells whether the device bound with the passed block device path is bootable. For that purpose, the output of 'parted' is analysed for search for the first partition id '1:' and the 'boot' keyward Requires root priviledges.
Returns 0 when device is bootable, false (1) when not, <0 on usage error. |
||||||
Dev__getBootType <arg1> |
This function uses gdisk to determine the type of the boot record of the device (if any) among GPT, MDR, APM and BSD, and request 'parted' to determine whether the device is actually bootable
|
||||||
Dev__wipeDisk <arg1> |
Erases any trace of a file system on the specified block device using wipefs
|
||||||
Dev__resetDiskDevice <arg1> |
Erases any trace of a file systems on the specified block device by zeroing the first 1M of the device. ATTENTION: this operation is destructive, use with care! ATTENITION: this may not work with GPT because there may be backup sectors, use wipefs -a --force
|
||||||
Dev__getDeviceFSType |
not documented |
||||||
Dev__createRawDiskImage <arg1> <arg2> <arg3> |
Generic low-level wrapper for creating a basic raw disk image filled with 0. This operation is time-consuming and may only be useful when handling disks in regular files.
Returns the value of 'dd' commands |
||||||
Dev__createSinglePartition <arg1> <arg2> <arg3> |
Generic low-level wrapper for creating a partition given a file system type. The type of partitition is deduced from the file system type, but not file system is created. Take care, this function can have destructive effect.
|
||||||
Dev__createSinglePartitionDirect <arg1> <arg2> <arg3> |
Generic low-level wrapper for creating directly a basic partition by script without having to specify a file system type in advance like Dev__createSinglePartition() function. Take care, this function can have destructive effect.
|
||||||
Dev__getDeviceMapper <arg1> <arg2> <arg3> |
Returns the device mapper name for a block device. If none exists, the original input block device path is returned. This function may be systematically called whatever the source is, which may result in message like "Device sdb1 not found Command failed." on stderr This is however harmless and shall be hidden, otherwise this misleads the log reader in thinking there’s an error.
|
||||||
Dev__getLVMPartitionDevices <arg1> |
|
||||||
Dev__getPartitionDevices <arg1> <arg2> |
Get the devices which are mapping partitions for the specified system device, which is assumed to be a top disk device. Uses sfdisk, partprobe,
|
||||||
Dev__deactivateAllVolumeGroupsForDisk <arg1> <arg2> |
Provided a disk block device, this function deactivates all volume groups inside that disk. It is assumed that partitions inside the volume group(s) have been unmounted. This uses 'vgchange -a n' command. Other commands, see 'Dev__getPartitionDevices'
Returns 0 if at least the partition of the devices could be resolved and VG could be deactivate, 1 otheriwse. |
||||||
Dev__loop_open <arg1> <arg2> <arg3> |
Allocates a loop device for the file specified as first argument.
Returns 0 only on sucess |
||||||
Vera__findMountPointFromVolume <arg1> <arg2> |
Retrieves the mounted folder for a Vera volume (file name) given as first argument.
|
||||||
Vera__findMountPointFromSlot <arg1> <arg2> |
Retrieves the mounted folder for a Vera slot number given as first argument.
|
||||||
Vera__findLabelFromMountPoint <arg1> <arg2> |
Retrieves the slot number from a VERA mountpoint.
|
||||||
Vera_getEscapedList |
This routine enables to get the vera list where all spaces within simple quites are espaced with '§§' chars, so that it can be safely processed by awk. It also redirects the standard error to /dev/null. |
||||||
Adb__getVersion |
not documented |
||||||
Adb__getSDKVersion |
not documented |
||||||
Adb__getDeviceName |
not documented |
||||||
Adb__listDevices |
not documented |
Multimedia file manipulation functions index
File: shell-api-multimedia.sh
| Function | Documentation | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Image__getDimension <arg1> <arg2> |
Enables the get the actual dimension of an image as returned by exiftool
|
||||||||||||||||||||
Image__isPortrait |
not documented |
||||||||||||||||||||
Image__chopFromRatio <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> <arg7> <arg8> <arg9> <arg10> |
Truncate passed image so that the ratio height/width for portrait images or ratio width/height for landscape images matches ratio. By the default, the target image file is not overwritten if it already exists , except if fifth argument is specified <image ratio threshold>
except that it is prefixed with "mobile_" When no specified, the image for mobile is not generated |
||||||||||||||||||||
Image__autoOrient |
not documented |
||||||||||||||||||||
Image__normalizeOrientation <arg1> <arg2> <arg3> |
Returns 0 if a change was done , 1 otherwise. |
||||||||||||||||||||
SVG_text |
not documented |
||||||||||||||||||||
Image__ico <arg1> |
Generates .ico from another image format in the specified target directory. The target icon will have the same as the original image and stored in the same folder.
|
||||||||||||||||||||
Image__generateFromPDF <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> |
Generates files of the form <PDF filebasename>-<image PPI>-<page>.jpg
pfgtocairo: resolution: -r, -rx , -ry (default is 150 PPI) -transp for transparent background with PNG |
||||||||||||||||||||
Image__generatePDFFromImageFiles |
not documented |
||||||||||||||||||||
Image__watermark |
not documented |
Packaging functions index
File: shell-api-packing.sh
| Function | Documentation | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Pkg__install <arg1> <arg2> <arg3> <arg4> <arg5> <arg6> <arg7> |
Installs the named packages according to the specified method. The URL can contain the following placeholders which will be replaced with actual values:
|
||||||||||||||||
DPKG__isInstalled <arg1> |
Checks whether a debian package passed as argument is installed.
|
||||||||||||||||
DPKG__exists <arg1> |
Checks whether the passed package name even exists for installation.
|
||||||||||||||||
APT__isInstalled <arg1> |
Checks whether a system APT package passed as argument is installed.
|
||||||||||||||||
APT__install <arg1> <arg2> |
Installs the list of APT packages given as argument.
|
||||||||||||||||
APT__distant_install <arg1> <arg2> |
Installs the list of APT packages given as argument.
|
||||||||||||||||
OPAM__isInstalled <arg1> |
Tells whether the passed OPAM package is installed.
Returns 0 if installed, another value otherwise. |
||||||||||||||||
OPAM__install <arg1> |
Installs the list of snap packages given as argument.
|
||||||||||||||||
SNAP__isInstalled <arg1> |
Tells whether the passed SNAP package is installed.
|
||||||||||||||||
SNAP__install <arg1> |
Installs the list of snap packages given as argument.
|
||||||||||||||||
GEM__isInstalled <arg1> |
Tells whether the passed GEM package is installed.
|
||||||||||||||||
GEM__install <arg1> |
Installs the list of GEM packages given as argument.
|
YAML file handling functions index
File: shell-api-yaml.sh
| Function | Documentation | ||||||
|---|---|---|---|---|---|---|---|
YAML__setFile <arg1> <arg2> |
Sets the currently processed YAML file passed as 1st argument (sets variable YAML__FILE) OR reads the YAML file all at once and stores the values in the global map YAML_DATA. The function YAML__read*, YAML__write*, YAML__keys* will access the file using yq each time. The function YAML__readAll, YAML__get*, YAML__getKeys*, YAML__writeAll, YAML__isUndefined, YAML__normalize, YAML__dumpAll will use the values stored in the global data map.
Returns 0 on success, any other value otherwise |
||||||
YAML__closeFile |
not documented |
||||||
YAML__getKeys <arg1> <arg2> |
Retrieves the keys defined below a given data path.
Returns 0 on success, any other value on error |
||||||
YAML__checkExists <arg1> |
Checks whether the field path exists in the global YAML_DATA map holding all data
Returns 0 on success, any other value on error |
||||||
YAML__get <arg1> <arg2> <arg3> |
Gets a YAML field from the global YAML_DATA map holding all data
is empty, then the input var is unchanged. |
||||||
YAML__isntVoid <arg1> |
Tells whether the passed value is not a 'void' YAML value, ie. it is neither 'null' nor ''.
|
||||||
YAML__unescape |
not documented |
||||||
YAML__escape |
not documented |
||||||
YAML__get_bool |
not documented |
||||||
YAML__get_int |
not documented |
||||||
YAML__isUndefined <arg1> |
Tells whether the value of the passed YAML field is either empty or 'null'. It reads the value using YAML__get using the passed key and check whether it is empty or 'null'
Returns Returns 0 when the passed YAML field value is either empty or 'null' |
||||||
YAML__getFilename <arg1> |
Get the currently processed YAML file as set with YAML__setFile.
Returns the return value of the yq command , i.e. 0 only on success. |
||||||
YAML__eval <arg1> |
Evaluates the rule passed as 1s argument from the currently set YAML file
Returns the return value of the yq command , i.e. 0 only on success. |
||||||
YAML__read <arg1> <arg2> |
Reads an YAML field using YAML__eval and stores the values in the passed named variable.
Returns the return value of the yq command , i.e. 0 only on success. |
||||||
YAML__read_from_stdin |
not documented |
||||||
YAML__read_optional <arg1> <arg2> |
Same as YAML__read() except that when the field path does not exist, the output variable remains unchanged and not error is raised.
Returns 0 if field exists and value was read, 1 otherwise |
||||||
YAML__read_bool |
not documented |
||||||
YAML__assignBool |
not documented |
||||||
YAML__read_int |
not documented |
||||||
YAML__write <arg1> <arg2> |
Writes in-place an YAML field
Returns the return value of the yq command , i.e. 0 only on success. |
||||||
YAML__writeArray <arg1> <arg2> |
Writes in-place an YAML array
Returns the return value of the yq command , i.e. 0 only on success. |
||||||
YAML__exists <arg1> |
Tells whether the YAML filter rule , resp. YAML field, is not 'null' in the currently set YAML file
Returns 0 when so, 1 otherwise |
||||||
YAML__keys <arg1> |
If YAML__exists is successfully, returns the keys of the matching YAML field.
Returns If rule result is not null, returns status of 'yq', 1 otherwise |
||||||
YAML__nbKeys_from_stdin |
not documented |
||||||
YAML__nbKeys |
not documented |
||||||
YAML__keys_from_stdin |
not documented |
||||||
YAML__writeAll |
not documented |
||||||
YAML__normalize |
not documented |
||||||
YAML__readAll <arg1> <arg2> |
|
||||||
YAML__readAll_getStoreValue |
not documented |
||||||
YAML__trimQuotes |
not documented |
||||||
YAML__readAll_storeRawValue |
not documented |
||||||
YAML__readAll_storeValue |
not documented |
||||||
YAML__readAll_decodeQuote |
not documented |
||||||
YAML__readAll_decodeArrayValue |
not documented |
||||||
YAML__dumpAll |
not documented |
||||||
YAML__getKeysFromStore |
This function returns the keys from the YAML data store. It only works if there’s one level of root nodes, otherwise it would return all nodes. This can be solve by checking the dots, but considering the node names might themselves contain dots. |
XML transformation functions index
File: shell-api-xslt.sh
| Function | Documentation |
|---|---|
XSLT__modifyXML |
not documented |
XSLT__transformToText |
not documented |
Framework self-test functions index
File: shell-api-selftest.sh
| Function | Documentation | ||||
|---|---|---|---|---|---|
testPerfTrim |
not documented |
||||
testGrepAndGetField |
not documented |
||||
testGetField |
not documented |
||||
testPerfGrepApi |
not documented |
||||
testGrepApi |
not documented |
||||
testTimer |
not documented |
||||
testYamlPerfReadAll |
not documented |
||||
testYamlOneFile |
not documented |
||||
testManyYamlTests |
not documented |
||||
testCommonEndString |
not documented |
||||
testAdbAPI |
not documented |
||||
testPkgInstallAlternative |
not documented |
||||
testDistroEnv |
not documented |
||||
testInputDirPath |
not documented |
||||
testLogStatus |
not documented |
||||
Test__printResult <arg1> <arg2> |
Use this function to display the test result
Returns mirrors first parameter |
||||
Test_File |
not documented |
||||
Test__File_in_out |
not documented |
||||
Test_URL |
not documented |
||||
Test__ProgressBar |
not documented |
||||
Test__Str_squeeze_testOneString |
not documented |
||||
Test__Str_escape_testOneString |
not documented |
||||
Test__Str_trim_testOneString |
not documented |
||||
Test__Str_eraseCommonTail |
not documented |
||||
Test__Str |
not documented |
||||
Test__Input__dirpath_checkOutput |
not documented |
||||
Test__Input__dirpath |
not documented |
||||
Test__Input__dirpath_forcedinput |
not documented |