sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

checklinks.sh (853B)


      1 #!/bin/sh
      2 # check internal wiki links, uses md-printlinks.c
      3 
      4 for t in */; do
      5 find "$t" -name "*.md" -type f | while read -r f; do
      6 	d=$(dirname "$f")
      7 	b=$(basename "$f")
      8 
      9 	./md-printlinks < "$f" | \
     10 		awk -F '\t' '
     11 /^(http|https|gopher|irc|ircs|git):\/\// { next; }
     12 /^\/\/(lists|dl|git|gunther|oldgit)\./ { next; }
     13 /^mailto:/ { next }
     14 /^\/\/suckless\.org\/atom\.xml$/ { next }
     15 {
     16 	print $0;
     17 }
     18 ' | \
     19 		while read -r -- l; do
     20 
     21 		# // relative
     22 		p="${l#//}"
     23 		if test x"$p" != x"$l"; then
     24 			bp="${p%%/*}"
     25 			# topmost dir doesn't exist, possibly // url to other site.
     26 			if ! test -d "$bp"; then
     27 				echo "$f	$l	$bp"
     28 				continue
     29 			fi
     30 			path="$p"
     31 		else
     32 			p="${l#/}"
     33 			if test x"$l" != x"$p"; then
     34 				# prefix is "/", use topmost dir + path.
     35 				path="$t/$l"
     36 			else
     37 				path="$d/$l"
     38 			fi
     39 		fi
     40 
     41 		test -e "$path" || echo "$f	$l	$path"
     42 	done
     43 done
     44 done