From 0a48bcb68f3fb5dd17600e884518806d4166b665 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 22 Feb 2014 16:54:20 +0100 Subject: [PATCH] [.bashrc] Stop find_up if directory does not exist --- .bashrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index d89108c..50f4f8b 100644 --- a/.bashrc +++ b/.bashrc @@ -45,12 +45,17 @@ fi # des infos quand on est dans un dépôt versionné find_up () { + local path normalized_path normalized_ret path="$1" shift 1 - while [[ "`readlink -f -- \"$path\"`" != "/" ]]; + normalized_path=`readlink -f -- "$path"` + normalized_ret=$? + while [[ "$normalized_path" != "/" ]] && [ $normalized_ret -eq 0 ]; do find "$path" -maxdepth 1 -mindepth 1 "$@" path=${path}/.. + normalized_path=`readlink -f -- "$path"` + normalized_ret=$? done } -- 2.39.2