diff --git a/libraries/common b/libraries/common index cec708d..e7eb082 100644 --- a/libraries/common +++ b/libraries/common @@ -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 #-------------------------------------------------------------------------------