implement 2 functions for customizing bash internal field separator

This commit is contained in:
belliash 2011-12-30 12:45:38 +01:00
parent 885ee46519
commit 766e280ead
1 changed files with 26 additions and 0 deletions

View File

@ -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
#-------------------------------------------------------------------------------