avoid wrong invoking from non-project directory
authorFrederick Zhang <Frederick888@Tsundere.moe>
Wed, 26 Aug 2015 18:31:46 +0000 (02:31 +0800)
committerFrederick Zhang <Frederick888@Tsundere.moe>
Wed, 26 Aug 2015 18:31:46 +0000 (02:31 +0800)
src/etc/cargo.bashcomp.sh

index 8aa12834e89aa1201f751a616ba3abd70d7ac84e..21cea0cae9c1378ea0714421f79cd056c25b904b 100644 (file)
@@ -100,9 +100,12 @@ _get_examples(){
 }
 
 _get_targets(){
+       local CURRENT_PATH=$(_locate_manifest)
+       if [[ -z "$CURRENT_PATH" ]]; then
+               return 1
+       fi
        local TARGETS=()
        local FIND_PATHS=( "/" )
-       local CURRENT_PATH=$(_locate_manifest)
        local FIND_PATH LINES LINE
        while [[ "$CURRENT_PATH" != "/" ]]; do
            FIND_PATHS+=( "$CURRENT_PATH" )