From 106d4dc2138483e208cb8955d6f6f32a7915839b Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Tue, 12 May 2015 18:09:10 +0200 Subject: [PATCH] Prune the cd history only if there was no error. --- bash-selector.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash-selector.sh b/bash-selector.sh index 7cb749c..dc7373b 100755 --- a/bash-selector.sh +++ b/bash-selector.sh @@ -72,8 +72,8 @@ function selector-cd () { if [[ -f "${SELECTOR_CD_HISTORY}" ]]; then TMP=$(mktemp /tmp/selector-cd.XXXXXX) - tail -$((SELECTOR_CD_HISTORY_SIZE-1)) < "${SELECTOR_CD_HISTORY}" > "${TMP}" - cat "${TMP}" > "${SELECTOR_CD_HISTORY}" + tail -$((SELECTOR_CD_HISTORY_SIZE-1)) < "${SELECTOR_CD_HISTORY}" > "${TMP}" && \ + cat "${TMP}" > "${SELECTOR_CD_HISTORY}" \rm -f "${TMP}" fi -- 2.20.1