sites

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

checklinks.sh (781B)


      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 		grep -vE '^(http|https|gopher|irc|ircs|git)://' | \
     11 		grep -vE '^\/\/(lists|dl|git|gunther)\.' | \
     12 		grep -vE '^mailto:' | \
     13 		while read -r -- l; do
     14 
     15 		# // relative
     16 		p="${l#//}"
     17 		if test x"$p" != x"$l"; then
     18 			bp="${p%%/*}"
     19 			# topmost dir doesn't exist, possibly // url to other site.
     20 			if ! test -d "$bp"; then
     21 				echo "$f	$l	$bp"
     22 				continue
     23 			fi
     24 			path="$p"
     25 		else
     26 			p="${l#/}"
     27 			if test x"$l" != x"$p"; then
     28 				# prefix is "/", use topmost dir + path.
     29 				path="$t/$l"
     30 			else
     31 				path="$d/$l"
     32 			fi
     33 		fi
     34 
     35 		test -e "$path" || echo "$f	$l	$path"
     36 	done
     37 done
     38 done