From 0e81e42e5faadf13bb6ef9fe6650f57cbce7422b Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 26 Jun 2014 02:26:57 -0700 Subject: [PATCH] fix edge case missing extglob --- lnf-function | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lnf-function b/lnf-function index 1780c8e..daae096 100644 --- 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 + 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" @@ -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 - # remove any trailing slashes + # remove any trailing slashes, uses extglob 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 + + $reset_extglob && shopt -u extglob ln -s -- "$@" } -- 2.30.2