Commit c83c2254 by Eric Coissac

Adds the ifs package

parent c2732536
#
# LECA Bash library
#
# The LECA bash library provides a set of function used for helping
# development of bash script mainly to write job script on the luke
# cluster
#
# The files from the LECA Bash library must be sourced from your main script
#
include stack
newstack LECABASH_IFS_STACK
function pushifs() {
if [[ -z "${IFS}" ]]; then
pushvalue LECABASH_IFS_STACK "@@NULL@@"
else
local v=$(echo -n "$IFS" | od -b | head -n +1 | sed 's/[0-9]* //' | sed 's/ /\\/g' | sed 's/^/\\/')
pushvalue LECABASH_IFS_STACK "$v"
fi
if [[ -z "$1" ]]; then
unset IFS
else
IFS="${1}"
fi
}
function popifs() {
local v
v=$(popvalue LECABASH_IFS_STACK v)
if [[ "$?"!="0" ]]; then
if [[ "$v"=="@@NULL@@" ]]; then
unset IFS
else
IFS=$(eval "echo -n \$'$x'")
fi
else
return 1
fi
return 0
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment