Browse Source

#181 Support --skip-existing in jenv-add

pull/65/merge
Gildas Cuisinier 8 years ago
parent
commit
e253e3654e
  1. 2
      libexec/jenv---version
  2. 17
      libexec/jenv-add

2
libexec/jenv---version

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
set -e
[ -n "$JENV_DEBUG" ] && set -x
version="0.4.4"
version="0.4.5-beta"
if [ -d $JENV_ROOT ]; then
cd "$JENV_ROOT"

17
libexec/jenv-add

@ -6,6 +6,7 @@ set -e @@ -6,6 +6,7 @@ set -e
# Provide jenv completions
if [ "$1" = "--complete" ]; then
echo "--skip-existing"
for d in ${!#}*; do
[[ -d "$d" ]] && echo $d/
done
@ -30,8 +31,9 @@ function cwarn() { @@ -30,8 +31,9 @@ function cwarn() {
function add_alias_check(){
if [ -h ${JENV_ROOT}/versions/$1 ];
if [ -h "${JENV_ROOT}/versions/$1" ];
then
if [ "$JENV_SKIP" = false ]; then
cwarn "There is already a $1 JDK managed by jenv"
read -p "Do you want to override (type y to confirm)? " -n 1 -r
echo ""
@ -40,6 +42,9 @@ function add_alias_check(){ @@ -40,6 +42,9 @@ function add_alias_check(){
rm -f "${JENV_ROOT}/versions/$1"
add_alias "$1"
fi
else
cinfo " $1 already present, skip installation"
fi
else
add_alias "$1"
@ -60,9 +65,16 @@ function add_alias(){ @@ -60,9 +65,16 @@ function add_alias(){
JENV_JAVAPATH="$1"
JENV_VERSION_FILE=".jenv-version"
JENV_SKIP=false
if [ $# -eq 2 ]; then
if [ "$1" = "--skip-existing" ]; then
echo "Ignore existings installations"
JENV_SKIP=true
JENV_JAVAPATH="$2"
else
cwarn "Warning : jenv add alias path/to/java_home is deprecated."
cwarn "Please prefer to let jenv generate unique alias name by using"
echo ""
@ -72,6 +84,7 @@ if [ $# -eq 2 ]; then @@ -72,6 +84,7 @@ if [ $# -eq 2 ]; then
JENV_JAVAPATH="$2"
JENV_ALIAS="$1"
fi;
fi;
if [ -f "$JENV_JAVAPATH/bin/java" ];

Loading…
Cancel
Save