local x ret prefix dir to_remove
+ local mkdir=false
to_remove=()
if [[ $nodir ]]; then
if [[ -e $2 || -L $2 ]]; then
to_remove+=("$2")
elif [[ ! -d $dir ]]; then
+ mkdir=true
if [[ -e $dir || -L $dir ]]; then
to_remove+=("$dir")
fi
- if ! mkdir -p "$(dirname "$2")"; then
- echo "lnf error: failed to make directory $(dirname "$2")"
- return 1
- fi
fi
elif (( $# >= 2 )); then
if [[ -d ${!#} ]]; then
fi
$reset_extglob && shopt -u extglob
+
+ if $mkdir; then
+ if ! mkdir -p "$(dirname "$2")"; then
+ echo "lnf error: failed to make directory $(dirname "$2")"
+ return 1
+ fi
+ fi
+
ln -s $nodir -- "$@"
}
lnf "$@"