wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

cleanname (273B)


      1 #!/bin/sh -f
      2 
      3 echo "$@" |
      4 	awk -F'/+' '{
      5 		delete a
      6 		n = 0
      7 		for(i = 1; i <= NF; i++) {
      8 			if($i == ".." && n > 0 && a[n] != "..")
      9 				n--
     10 			else if($i != "" && $i != ".")
     11 				a[++n] = $i
     12 		}
     13 		s = ""
     14 		for(i = 1; i <= n; i++)
     15 			s = s "/" a[i]
     16 		print substr(s, 2)
     17 	}'
     18