X-Git-Url: https://iankelling.org/git/?p=lnf;a=blobdiff_plain;f=lnf-function;h=0d43112818fbc1ef4a59722cdd41665eb003f25d;hp=9dbcef5ac4e2183f7013db3f22ddb6d523078b2f;hb=fae0c9143e694a3ed895cee68d1adad9bc359f05;hpb=056e6160cd38fa3bf1622ed4f4c0179f84b53c2f diff --git a/lnf-function b/lnf-function index 9dbcef5..0d43112 100644 --- a/lnf-function +++ b/lnf-function @@ -15,7 +15,7 @@ Create directory if needed. Slightly more restrictive arguments than ln. In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd form, create a link to TARGET in the current directory. In the 3rd form, create links to each TARGET in DIRECTORY." - + if [[ $1 == --help || $# -eq 0 ]]; then echo "$help" return 0 @@ -30,19 +30,19 @@ links to each TARGET in DIRECTORY." return 1 fi fi - + local reset_extglob=false ! shopt extglob >/dev/null && reset_extglob=true shopt -s extglob - + local remove x if type -P trash-put >/dev/null; then remove=trash-put else remove="rm -rf" fi - + if [[ $nodir ]]; then if [[ -e "$2" || -L "$2" ]]; then $remove "$2" @@ -72,6 +72,6 @@ links to each TARGET in DIRECTORY." [[ -e "${1##*/}" || -L "${1##*/}" ]] && $remove "${1##*/}" fi - $reset_extglob && shopt -u extglob + $reset_extglob && shopt -u extglob ln -s $nodir -- "$@" }