#!/bin/bash

set -- -l . # for test purposes: set argument list to long-list current directory

usage() {
	printf >&2 'USAGE: %s [-l] path\n' "$0"
	exit 2
}

long=0

while getopts 'l' option; do
	case "$option" in
		l) long=1 ;;
		*) usage ;;
	esac
done

shiftval=$(( OPTIND - 1 ))
if (( $# < shiftval )); then
	usage
fi
shift "$shiftval"

if (( $# != 1 )); then # 1 is number of required positional arguments
	usage
fi

path="$1"

if (( long == 1 )); then
	ls -l -- "$path"
else
	ls -- "$path"
fi