Commons API

API

assertNot

Check if last command result (passed in input). If result is equal to res_value param print message to stdout and exit with value 1.

Parameters:

  • $1: result value of the command
  • $2: check if result value is equal to this value. (numeric value)
  • $3: message to print if result is not equal to zero
(Show/Hide)

error_handled

Check if last command result. If result is not equal to 0 then print a message to stdout and exit with value 1.

Parameters:

  • $1: message to print if result is not equal to zero.
(Show/Hide)

error_generate

Print input message and exit with value 1 if second parameter is not equal to 0.

Parameters:

  • $1: message to print on stdout.
  • $2: optional field to avoid call to exit program if value is equal to 0.
(Show/Hide)

check_var

Check if variable with name in input contains a string or not.

Parameters:

  • $1: name of the variable to check.

Returns:

  • 1: length of the variable is zero
  • 0: length of the variable is not zero
(Show/Hide)

escape_var

Escape content of the variable with input name.

Parameters:

  • $1: name of the variable to check.

Returns:

  • 0: always
(Show/Hide)

escape2oct_var

Escape content of the variable with input name like escape_var with octets ascii code.

Parameters:

  • $1: name of the variable to check.

Returns:

  • 0: always
(Show/Hide)

confirmation_question

Use to generate an input question and manage response.

Parameters:

  • $1: message with question for user.

Returns:

  • 0: if user answer is yes.
  • 1: if if user answer is no.
  • 2: if user answer empty.
(Show/Hide)

push_spaces

Push spaces to stdout.

Parameters:

  • $1: Number of spaces to write.

Returns:

  • 0: always
(Show/Hide)

get_space_str

Create a string with input "str" param at begin and N spaces where N is equal to max_chars - ${#str}

Parameters:

  • $1: (var_name) Name of variable where save string with spaces.
  • $2: (max_chars) Number of max chars of the string with spaces.
  • $3: (str) String to insert at begin of save string.
  • $4: (pre_spaces) Number of spaces to add before str. (Optional. default 0).

Returns:

  • 0: on success
  • 1: on error
(Show/Hide)

commons_exists_prog

Check if a program is available on current PATH.

Parameters:

  • $1: (program) Name of the program.
  • $2: (options) Override default (-v) option on check presence. Optional.

Returns:

  • 0: if program exists
  • 1: if program doesn't exists or invalid input params.
(Show/Hide)