All pastes #980021 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-10 19:09 UTC
rendered paste body
#!/bin/bash

# Author           : Martti Kühne
# Created On       : Thu Apr 10 20:07:29 CEST 2008
# Created On Node  : base (my laptop)
# Last Modified By : Martti Kühne
# Last Modified On : Thu Apr 10 20:07:29 CEST 2008
# Last Machine Used: base (my laptop)
# Update Count     : 1
# Status           : Initial
# HISTORY          : 
# Description      : $($progname -h)

# make sure we exit on error
set -e

progname="`basename \"$0\"`"
pversion='$Revision: 1.0 $'

# echoes the full path or returns 1
fullp() {
	[ -d "$@" ] || return 1
	[ "${@:0:1}" = "/" ] || echo -n "$(pwd)/"
	echo "$@"
}

usageversion() {
		cat >&2 <<EOF
GNU/Linux $progname $version
           Copyright (C) 2008 Martti Kühne.
This is free software; see the GNU General Public Licence for copying
conditions.  There is NO warranty.

Usage: $progname [options] source destination
Options:
     -h,     --help          print this message
     -d, --dir-each          create a directory for each archive
     -p, --preserve          preserve the subdirectory structure
     source                  the source directory
     destination             the destination directory
EOF
}

srcdir="unset"
destdir="unset"
dir_each=0
preserve=0

while [ -n "$1" ]; do
	case "$1" in
	-h|--help)
		usageversion
		exit 0
	;;
	-d|--dir-each)
		dir_each=1
	;;
	-p|--preserve)
		preserve=1
	;;
	*)
		if [ "$srcdir" = "unset" ]; then
			srcdir="$1"
		elif [ "$destdir" = "unset" ]; then
			destdir="$1"
		else
			echo >&2 "error: invalid command line option: $1"
			usageversion
			exit 1
		fi
	;;
	esac
	shift
done