From: Valentin Samir Date: Sat, 22 Feb 2014 15:54:20 +0000 (+0100) Subject: [.bashrc] Stop find_up if directory does not exist X-Git-Url: http://gitweb.pimeys.fr/?p=config-20-100.git;a=commitdiff_plain;h=0a48bcb68f3fb5dd17600e884518806d4166b665 [.bashrc] Stop find_up if directory does not exist --- 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 }