Made the UMASK variables local, otherwise selector-cd-search still changes the umask.
[selector.git] / bash-selector.sh
index ac094c8..7246d45 100755 (executable)
@@ -61,6 +61,7 @@ export SELECTOR_CD_HISTORY_SIZE
 # The function to use in place of the standard "cd"
 
 function selector-cd () {
+    local UMASK=$(umask)
     umask 077
 
     if [[ -z "$1" ]]; then
@@ -73,13 +74,15 @@ function selector-cd () {
         TMP=$(mktemp /tmp/selector-cd.XXXXXX)
         tail -$((SELECTOR_CD_HISTORY_SIZE-1)) < "${SELECTOR_CD_HISTORY}" > "${TMP}"
         cat "${TMP}" > "${SELECTOR_CD_HISTORY}"
-        rm -f "${TMP}"
+        \rm -f "${TMP}"
     fi
 
     echo "${PWD}" | sed -e "s!^${HOME}!~!" >> "${SELECTOR_CD_HISTORY}"
+    umask ${UMASK}
 }
 
 function selector-cd-search () {
+    local UMASK=$(umask)
     umask 077
 
     if [[ -f "${SELECTOR_CD_HISTORY}" ]]; then
@@ -93,6 +96,7 @@ function selector-cd-search () {
     else
         echo "No cd history file '${SELECTOR_CD_HISTORY}'." >&2
     fi
+    umask ${UMASK}
 }
 
 alias cd=selector-cd
@@ -101,8 +105,8 @@ alias cd=selector-cd
 # The key-bindings themselves
 ######################################################################
 
-    # M-t appends the selected history line and the end of the current
-    # one bind '"\C-[t":"\C-a\C-kselector-history\C-m\C-a\C-y\C-e"'
+# M-t appends the selected history line and the end of the current
+# one bind '"\C-[t":"\C-a\C-kselector-history\C-m\C-a\C-y\C-e"'
 
 if [[ "$1" ]]; then