Detect SCM tool presence just once

For git/svn/hg, the tool presence in $PATH is detected just once at init
time (instead of at runtime, at every prompt display) and the LP_ENABLE_
variable is set to false if it is missing.
This commit is contained in:
Olivier Mengué 2012-08-16 16:39:20 +02:00
parent 7d4ca77009
commit b52cb624bc

View File

@ -265,6 +265,12 @@ _lp_source_config()
# do source config files # do source config files
_lp_source_config _lp_source_config
# Disable features if the tool is not installed
[[ "$LP_ENABLE_GIT" = 1 ]] && { command -v git >/dev/null || LP_ENABLE_GIT=0 ; }
[[ "$LP_ENABLE_SVN" = 1 ]] && { command -v svn >/dev/null || LP_ENABLE_SVN=0 ; }
[[ "$LP_ENABLE_HG" = 1 ]] && { command -v hg >/dev/null || LP_ENABLE_HG=0 ; }
############### ###############
# Who are we? # # Who are we? #
@ -540,7 +546,6 @@ _lp_git_branch()
_lp_git_branch_color() _lp_git_branch_color()
{ {
[[ "$LP_ENABLE_GIT" == 1 ]] || return [[ "$LP_ENABLE_GIT" == 1 ]] || return
command -v git >/dev/null 2>&1 || return 1;
local branch local branch
branch=$(_lp_git_branch) branch=$(_lp_git_branch)
if [[ ! -z "$branch" ]] ; then if [[ ! -z "$branch" ]] ; then
@ -608,7 +613,6 @@ _lp_hg_branch()
_lp_hg_branch_color() _lp_hg_branch_color()
{ {
[[ "$LP_ENABLE_HG" == 1 ]] || return [[ "$LP_ENABLE_HG" == 1 ]] || return
command -v hg >/dev/null 2>&1 || return 1;
local branch local branch
local ret local ret
branch=$(_lp_hg_branch) branch=$(_lp_hg_branch)
@ -656,7 +660,6 @@ _lp_svn_branch()
_lp_svn_branch_color() _lp_svn_branch_color()
{ {
[[ "$LP_ENABLE_SVN" == 1 ]] || return [[ "$LP_ENABLE_SVN" == 1 ]] || return
command -v svn >/dev/null 2>&1 || return 1;
local branch local branch
branch=$(_lp_svn_branch) branch=$(_lp_svn_branch)
if [[ ! -z "$branch" ]] ; then if [[ ! -z "$branch" ]] ; then