#!/bin/bash
#
# "gziplinks" script
# Version 0.1 by Giacomo Lozito
# Last edited on 16/2/2005
# License: General Public License v2
#
# This script removes symbolic links to man pages, gzippes
# them and then rebuilds symbolic links for gzipped man pages
# IT DOES THE JOB IN THE CURRENT WORKING DIRECTORY!
#

read -n1 -p "This will gzip and rebuild links for
all directory content. Continue? (y/n) " _USERKEYPRESS
echo ""

if [ ! `echo -n $_USERKEYPRESS | grep y` ]
then
  exit 0
fi

gzip -9 -q *
for _MANSYMLINK in `ls -F | grep @$ | tr -d @`
do
	_MANDESTLINK=`readlink $_MANSYMLINK`
	rm $_MANSYMLINK
	ln -s $_MANDESTLINK.gz $_MANSYMLINK.gz
done

echo "Directory content gzipped and links rebuilt!"
