From 20fc4284852acbc7625edbf36f48d73306189e5f Mon Sep 17 00:00:00 2001 From: Kieran Doonan Date: Mon, 24 Aug 2015 12:45:20 +0100 Subject: [PATCH] Updated _chef_root function to use directory:h --- plugins/knife/_knife | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/knife/_knife b/plugins/knife/_knife index 4e7ee69ae..0d61ff15c 100644 --- a/plugins/knife/_knife +++ b/plugins/knife/_knife @@ -230,12 +230,11 @@ _cookbook_versions() { # Searches up from current directory to find the closest folder that has a .chef folder # Useful for the knife upload/from file commands _chef_root () { - slashes=${PWD//[^\/]/} directory="$PWD" - for (( n=${#slashes}; n>0; --n )) + while [ $directory != '/' ] do test -e "$directory/.chef" && echo "$directory" && return - directory="$directory/.." + directory="${directory:h}" done }