shell-var(3)
shell_var_is_no, shell_var_is_yes, shell_var_is_number, shell_var_trim, shell_var_unquote - functions to trim spaces in the value of the variable
- shell_var_trim varname value
- shell_var_unquote varname value
- shell_var_is_no value
- shell_var_is_yes value
- shell_var_is_number
Function strips whitespace from the beginning and end of a string
Example:
shell_var_trim retval " aaa bb aaa "; echo "[$retval]"
[aaa bb aaa]
Function removes quote symbol from string
Example:
for i in "\"str1\"" "'str2'" "\"str3'"; do
shell_var_unquote var "$i";
echo "$var";
done
Output:
str1
str2
"str3'
Function checks whether the variable means "no".
Function checks whether the variable means "yes".
Function checks whether the variable is positive number.
Example:
shell_var_is_number '123' && echo OK || echo NOP
shell_var_is_number '420' && echo OK || echo NOP
shell_var_is_number 'a42' && echo OK || echo NOP
shell_var_is_number '2 0' && echo OK || echo NOP
Output:
OK
OK
NOP
NOP
Authors and contributors of the programs included in the libshell package are listed in the COPYING file.
Report bugs to the authors.