sane-sandboxed: fix typos in normPath
This commit is contained in:
parent
6c65e4b313
commit
567531727e
|
@ -184,34 +184,34 @@ splitHead() {
|
|||
# chomps trailing slashes.
|
||||
# does not resolve symlinks, nor check for existence of any component of the path.
|
||||
normPath() {
|
||||
local npOut="$1"
|
||||
local npUnparsed="$2"
|
||||
local npComps=()
|
||||
while [ -n "$_npUnparsed" ]; do
|
||||
splitHead _npThisComp _npUnparsed "$_npUnparsed"
|
||||
npUnparsed="$_npUnparsed"
|
||||
local npThisComp="$_npThisComp"
|
||||
local outVar="$1"
|
||||
local unparsed="$2"
|
||||
local comps=()
|
||||
while [ -n "$unparsed" ]; do
|
||||
splitHead _npThisComp _npUnparsed "$unparsed"
|
||||
unparsed="$_npUnparsed"
|
||||
local thisComp="$_npThisComp"
|
||||
|
||||
if [ "$npThisComp" = "/.." ]; then
|
||||
if [ "$thisComp" = "/.." ]; then
|
||||
# "go up" path component => delete the leaf dir (if any)
|
||||
if [ ${#npComps[@]} -ne 0 ]; then
|
||||
unset npComps[-1]
|
||||
if [ ${#comps[@]} -ne 0 ]; then
|
||||
unset comps[-1]
|
||||
fi
|
||||
elif [ "$npThisComp" != "/." ] && [ "$npThisComp" != "/" ] && [ "$npThisComp" != "" ]; then
|
||||
elif [ "$thisComp" != "/." ] && [ "$thisComp" != "/" ] && [ "$thisComp" != "" ]; then
|
||||
# normal, non-empty path component => append it
|
||||
npComps+=("$npThisComp")
|
||||
comps+=("$thisComp")
|
||||
fi
|
||||
done
|
||||
|
||||
# join the components
|
||||
if [ ${#npComps[@]} -eq 0 ]; then
|
||||
declare -g "$npOut"="/"
|
||||
if [ ${#comps[@]} -eq 0 ]; then
|
||||
declare -g "$outVar"="/"
|
||||
else
|
||||
local npJoined=
|
||||
for npComp in "${npComps[@]}"; do
|
||||
npJoined="$npJoined$npComp"
|
||||
local joined=
|
||||
for comp in "${comps[@]}"; do
|
||||
joined="$joined$comp"
|
||||
done
|
||||
declare -g "$npOut"="$npJoined"
|
||||
declare -g "$outVar"="$joined"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user