maillog: 12/01/2005-14:50:39(-0800): Jeremy Huddleston types
> while [ "${removed}" != "$(echo ${removed} | sed -e
> 's:[^/]*/\.\./::')" ]; do
> removed=$(echo ${removed} | sed -e 's:[^/]*/\.\./::')
> done
What about:
function clean..() {
local p="$1"
p1="${p%%\/..\/*}"
p2="${p#*\/..\/}"
p="${p1%\/*}/${p2}"
# echo ">> [${p}]" >&2
while [ "${p}" != "${p//\/..\/}" ];
do
p=$(clean.. "${p}")
done
echo "${p}"
}
It will only clean occurrences of "/../". If you have a trailing ".." it
won't do it, but it won't break much either:
$ clean.. 11/22/33/44/../../a/b/../../
11/22/
$ clean.. 11/22/33/44/../../a/b/../..
11/22/a/..
11/22/a/.. is still a valid path, pointing to the proper destination.
--
> Georgi Georgiev > A mushroom cloud has no silver lining. >
< [EMAIL PROTECTED] < <
> +81(90)6266-1163 > >
pgpoQUvgOpLTP.pgp
Description: PGP signature
