wmii/util/cleanname

19 lines
273 B
Plaintext
Raw Normal View History

#!/bin/sh -f
echo "$@" |
2007-07-01 23:26:14 +04:00
awk -F'/+' '{
delete a
n = 0
for(i = 1; i <= NF; i++) {
if($i == ".." && n > 0 && a[n] != "..")
n--
else if($i != "" && $i != ".")
a[++n] = $i
}
s = ""
for(i = 1; i <= n; i++)
s = s "/" a[i]
print substr(s, 2)
}'