Documentation for the functions in (snippet_functions.sh).
If the pipes are not documented, the default is:
stdin
: piped input ignoredstdout
: empty
Parameters enclosed in brackets [ ] are optional.
Returns with status 0 if the shell has a "definition" for the command $1
, regardless what type it is (function, built-in,
file, etc.). It's similar to which
but may also be used for bash functions and helps avoid "command ... unknown" errors. It
may be used in instruction chains:
is_command_defined "tail" && tail "..."
will only call tail
if it's defined (aka installed). The example shows an essential difference with
is_function_defined() which will always return status 1 (not defined) for tail
because it
has the type file, not function.
Param. | $1 | name of the function |
Status | 0 | function $1 is defined |
1 | function $1 is not defined |
Returns with status 0 if a bash function with the name $1
exists. Useful to avoid "command ... unknown" errors.
Important: do not use this function to check for the availability of standard shell utilities like echo
or tail
f.ex. - these
are not considered functions by bash (types builtin and file, respectively). Even if they are defined, this function returns
status 1 (not defined) - use is_command_defined() instead.
Example of the use in an instruction chain:
is_function_defined "log" && log "..."
will only call log
if it's defined.
Param. | $1 | name of the function |
Status | 0 | function $1 is defined |
1 | function $1 is not defined |
Returns the piped stdin
content on stdout
, which allows to capture it into a variable, here f.ex. to $input
:
input="$(get_piped_input)"
Pipes | stdin | read completely |
stdout | copy of stdin 's piped input | |
Status | 0 |