#!/bin/bash -efu
# This script affords find(1) an alternate interface that lets find(1)
# find files even if one or more of the BASE... begin with a hyphen.
# Inconveniently, the PREOPTS and POSTOPTS must each be passed as
# single strings.
#
# usage: findx PREOPTS POSTOPS [BASE...]
# example: findx '-L' '-name '"'"'bar baz'"'"' -type f' dir1 dir2
# (In the example, 'bar baz' is the unconventional name of a single file.)
readonly PREOPTS=$1 POSTOPTS=$2; shift 2; BASE=("$@")
declare -i I
for I in ${!BASE[@]}; do
    [[ ${BASE[$I]} = /* ]] || BASE[$I]="./${BASE[$I]}"
done
readonly BASE
readonly BASES=$(for B in "${BASE[@]}"; do printf "'%s' " "$B"; done;)
eval "exec find $PREOPTS $BASES $POSTOPTS"
exit 1 # unreachable
