implement 2 functions for customizing bash internal field separator
This commit is contained in:
parent
885ee46519
commit
766e280ead
|
@ -125,6 +125,18 @@ function printWarn() {
|
|||
echo -e " ${MESSAGE_WARN} ${@}"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Restores original Internal Field Separator (IFS)
|
||||
#-------------------------------------------------------------------------------
|
||||
function restoreIFS() {
|
||||
if [ "${ORGIFS:-unset}" != "unset" ]; then
|
||||
IFS="${ORGIFS}"
|
||||
unset ORGIFS
|
||||
else
|
||||
unset IFS
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Silently executes given command and saves its output to log file if enabled
|
||||
# Parameters: %command%
|
||||
|
@ -138,6 +150,20 @@ function run() {
|
|||
return ${RESULT}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Saves original Internal Field Separator (IFS) and optionally sets new value
|
||||
# Parameters: %new_ifs%
|
||||
#-------------------------------------------------------------------------------
|
||||
function saveIFS() {
|
||||
if [ "${IFS:-unset}" != "unset" ]; then
|
||||
ORGIFS="${IFS}"
|
||||
fi
|
||||
local NEWIFS="${1}"
|
||||
if isSet NEWIFS; then
|
||||
IFS="${NEWIFS}"
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Returns a UNIX timestamp
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue