#!/bin/sh

# List directories, but not files (tested on Linux and FreeBSD)

# Exclude dot files by default
all='.*'
one='x'
# Get "long", "all", and "one" options
while getopts  ":la1" flag
do
    case $flag in
        l)    long='l';one='';;
        a)    all='';;
        1)    one='1';;
        ?)   printf "Error: Unknown option '-$OPTARG'\nUsage: %s [-la1] [dir ...]\n" `basename $0`; exit 2;;
    esac
done
# Shift option(s) off array if present 
test $OPTIND -gt 1 && shift
# Set array to current directory only if no more args.
test -z "$1" && set . 
for dir in "$@"; do
    if test -d "${dir}"; then
        find "${dir}" -mindepth 1 -maxdepth 1 -type d ! -name "${all}" -print0 | sort -z | sed 's=\./==g' | tr -d '\n' | xargs -0 ls -d${long}${one}| grep -v '\.$'
    fi
done
