iankelling.org
/
git
/
lnf
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor doc update
[lnf]
/
lnf-function
diff --git
a/lnf-function
b/lnf-function
index 1780c8e571fd4147703098ce38bc415b60752ba9..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"
@@
-41,7
+45,7
@@
replacing a file but not a directory. No ln option arguments are supported."
local oldcwd=$PWD
cd "${!#}" # last arg
for x in "${@:1:$(( $# - 1 ))}"; do # all but last arg
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##*/}"
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 -- "$@"
}