summaryrefslogtreecommitdiffstats
path: root/util/bin/hrefs
blob: 3a1a51de5bf5498c22caa3cdd0b045278b909238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh

_hrefs() {
  sed -n 's/href="\([^"]\+\)"/\n&\n/gp' |
      sed -n 's/^href="\([^"]\+\)"$/\1/p'; }

_add_prefix_to_relative_hrefs() {
  sed '/^http:/!s^'"$1"''; }

_main() {
  case $# in
    (0) _hrefs;;
    (1) _hrefs | _add_prefix_to_relative_hrefs "$1";;
    (*)
      echo "bad command line: $0 $*" >&2; exit 23;;
  esac; }

set -euf
_main "$@"
#### end of file.