shift
fi
+ local reset_extglob=false
+ ! shopt extglob >/dev/null && reset_extglob=true
+ shopt -s extglob
+
local remove x
- if type -P dircolors >/dev/null; then
+ if type -P trash-put >/dev/null; then
remove=trash-put
else
remove="rm -rf"
local oldcwd=$PWD
cd "${!#}" # last arg
for x in "${@:1:$(( $# - 1 ))}"; do # all but last arg
- # remove any trailing slashes
+ # remove any trailing slashes, uses extglob
x="${x%%+(/)}"
# remove any leading directory components
x="${x##*/}"
elif [[ $# -eq 1 ]]; then
[[ -e "${1##*/}" || -L "${1##*/}" ]] && $remove "${1##*/}"
fi
+
+ $reset_extglob && shopt -u extglob
ln -s -- "$@"
}