gencrumbs (391B) [raw]
1 #!/bin/sh 2 # generate breadcrumbs 3 set -e 4 die() { 5 echo "$*" 1>&2 6 exit 1 7 } 8 9 [ -z "$1" ] && die "usage: gencrumbs FILE" 10 11 REPO=$(dirname "$(dirname "$(readlink -f "$0")")") 12 FILE=$(readlink -f "$1") 13 14 rel=${FILE##$REPO/www} 15 parts=$(echo "$rel" | sed 's#/# #g') 16 17 printf "/home/alex" 18 for p in $parts; do 19 if [ "$p" = "index.html" ]; then 20 continue 21 fi 22 printf "/$p" 23 done 24 echo