From 7737eb87dbc83b5555828694603bd32a4827b480 Mon Sep 17 00:00:00 2001 From: Atsushi SAKAI Date: Fri, 13 Nov 2015 13:57:49 +0900 Subject: [PATCH] Update virtualenv, pip and git existent check in cli-ref tool In the cli auto generation tool default, it uses /usr/bin only for virtualenv, pip and git But ubuntu server installs these two commands to /usr/local/bin. This patch searches these commands by the which command. If it cannot find these commands in the search path, it reports error. Closes-Bug: #1515878 Change-Id: I61ed42d27724a5abb72748beb58c1c012c52a3f6 --- bin/doc-tools-update-cli-reference | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/bin/doc-tools-update-cli-reference b/bin/doc-tools-update-cli-reference index a3f380ee..daa5e66a 100755 --- a/bin/doc-tools-update-cli-reference +++ b/bin/doc-tools-update-cli-reference @@ -21,20 +21,19 @@ fi project=$1 -if [[ ! -e /usr/bin/virtualenv ]]; then - echo "error: virtualenv not installed" - exit 1 -fi +# checks command exist or not +function does_exist { + which $@ > /dev/null 2>&1 + local status=$? + if [[ $status -ne 0 ]]; then + echo "error: $1 not installed" + exit 1 + fi +} -if [[ ! -e /usr/bin/pip ]]; then - echo "error: pip not installed" - exit 1 -fi - -if [[ ! -e /usr/bin/git ]]; then - echo "error: git not installed" - exit 1 -fi +does_exist virtualenv +does_exist pip +does_exist git if [[ ! -e $HOME/.gitconfig ]]; then echo "note: ~/.gitconfig does not exist"