Browse Source

implement 2 functions for customizing bash internal field separator

master
belliash 10 years ago
parent
commit
766e280ead
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      libraries/common

+ 26
- 0
libraries/common 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
#-------------------------------------------------------------------------------


Loading…
Cancel
Save