[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

lh_clean rewrite with functions



On Mon, Nov 19, 2007 at 03:15:20PM +0100, Fathi Boudra wrote:
> Hi,
> 
> after falling on :
> 
> sudo lh_clean
> lh_clean: unrecognized option `--chroot'
> 
> i looked at lh_clean and find cleaner to rewrite it with functions.
> Maybe applicable somewhere else...
You can also do something like

while [ $# -ne 0 ]
do
	arg=$1
	case $1 in
	[^-]*)
		break
		;;

	--clean|--purge|--stage|--source|...)
		f=${arg#--}
		$f
		;;

	--otheroption)
		shift
		something=$1

	*)
		exec >&2
		echo "Unknown option: $1"
		echo "Run $0 --help for help."
		exit 1
		;;
	esac

	shift || { echo "Option requires an argument: $arg"; exit 2; } >&2
done



Reply to: