]> gitweb.pimeys.fr Git - config-20-100.git/commitdiff
[.bashrc] Stop find_up if directory does not exist
authorValentin Samir <valentin.samir@crans.org>
Sat, 22 Feb 2014 15:54:20 +0000 (16:54 +0100)
committerValentin Samir <valentin.samir@crans.org>
Sat, 22 Feb 2014 15:54:20 +0000 (16:54 +0100)
.bashrc

diff --git a/.bashrc b/.bashrc
index d89108c3c8b8c6042a8213f5464c1a788ad02864..50f4f8b128af1de598c998cce3a270f7663701b9 100644 (file)
--- 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
 }