#!/bin/sh -e

update-alternatives --quiet --install /usr/bin/awk awk /usr/bin/mawk 20 \
  --slave /usr/man/man1/awk.1.gz awk.1.gz /usr/man/man1/mawk.1.gz \
  --slave /usr/bin/nawk nawk /usr/bin/mawk \
  --slave /usr/man/man1/nawk.1.gz nawk.1.gz /usr/man/man1/mawk.1.gz
for badlink in /usr/man/man1/awk.1 /usr/man/man1/nawk.1; do
  if [ -L $badlink ]; then
    if ! ls -l $(ls -l $badlink | cut -d">" -f2) &>/dev/null; then
      rm -f $badlink; fi; fi; done

exit 0
