iankelling.org
/
git
/
lnf
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix edge case missing extglob
[lnf]
/
lnf-function
diff --git
a/lnf-function
b/lnf-function
index 61478e7cddab32b3e2e9834c3074e5097ada43e9..daae096c035f51d63500a5f526d79403e260a6ee 100644
(file)
--- a/
lnf-function
+++ b/
lnf-function
@@
-22,9
+22,13
@@
replacing a file but not a directory. No ln option arguments are supported."
shift
fi
shift
fi
+ local reset_extglob=false
+ ! shopt extglob >/dev/null && reset_extglob=true
+ shopt -s extglob
+
local remove x
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"
remove=trash-put
else
remove="rm -rf"
@@
-39,9
+43,9
@@
replacing a file but not a directory. No ln option arguments are supported."
elif [[ $# -ge 2 ]]; then
if [[ -d ${!#} ]]; then
local oldcwd=$PWD
elif [[ $# -ge 2 ]]; then
if [[ -d ${!#} ]]; then
local oldcwd=$PWD
- cd
${!#}
# last arg
- for x in "${@:1:$((
$#-1
))}"; do # all but last arg
- # remove any trailing slashes
+ cd
"${!#}"
# last arg
+ for x in "${@:1:$((
$# - 1
))}"; do # all but last arg
+ # remove any trailing slashes
, uses extglob
x="${x%%+(/)}"
# remove any leading directory components
x="${x##*/}"
x="${x%%+(/)}"
# remove any leading directory components
x="${x##*/}"
@@
-54,5
+58,7
@@
replacing a file but not a directory. No ln option arguments are supported."
elif [[ $# -eq 1 ]]; then
[[ -e "${1##*/}" || -L "${1##*/}" ]] && $remove "${1##*/}"
fi
elif [[ $# -eq 1 ]]; then
[[ -e "${1##*/}" || -L "${1##*/}" ]] && $remove "${1##*/}"
fi
+
+ $reset_extglob && shopt -u extglob
ln -s -- "$@"
}
ln -s -- "$@"
}