Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Created April 10, 2023 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/ba3f26e199803e516af326b23372d6eb to your computer and use it in GitHub Desktop.
Save jrichardsz/ba3f26e199803e516af326b23372d6eb to your computer and use it in GitHub Desktop.
maven helper
mvn_detect() {
maven_version=$(mvn -v > /dev/null 2>&1)
status=$?
echo $status
}
java_detect() {
java_version=$(java -version > /dev/null 2>&1)
status=$?
echo $status
}
sudo_detect() {
prompt=$(sudo -nv > /dev/null 2>&1)
status=$?
echo $status
}
echo "Hello I am the maven version manager wellknowed as mvm"
if [ "$(sudo_detect)" -eq "0" ]; then
echo ">> sudo is allowed"
if [ "$(java_detect)" -eq "0" ]; then
echo ">> java is available"
if [ "$(mvn_detect)" -eq "0" ]; then
echo ">> mvn is already in this machine."
else
echo ">> mvn is not available in this machine."
fi
else
echo ">> java is not installed. Java is required to maven installation"
fi
else
echo "sudo is not allowed. Bye!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment