From 9e7d7c26e9f6e7fd2a3e2a6e8a2585cf9a7ff3b8 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Fri, 21 Sep 2018 14:42:51 +0800 Subject: [PATCH] fix debug support. #128 --- bin/as.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/as.sh b/bin/as.sh index ead41376..1c11bf7a 100755 --- a/bin/as.sh +++ b/bin/as.sh @@ -297,11 +297,15 @@ parse_arguments() # check pid if [ -z ${TARGET_PID} ] && [ ${BATCH_MODE} = false ]; then # interactive mode + # backup IFS: https://github.com/alibaba/arthas/issues/128 + local IFS_backup=$IFS IFS=$'\n' CANDIDATES=($(${JAVA_HOME}/bin/jps -l | grep -v sun.tools.jps.Jps | awk '{print $0}')) if [ ${#CANDIDATES[@]} -eq 0 ]; then echo "Error: no available java process to attach." + # recover IFS + IFS=$IFS_backup return 1 fi @@ -337,7 +341,8 @@ parse_arguments() fi TARGET_PID=`echo ${CANDIDATES[$(($choice-1))]} | cut -d ' ' -f 1` - + # recover IFS + IFS=$IFS_backup elif [ -z ${TARGET_PID} ]; then # batch mode is enabled, no interactive process selection. echo "Illegal arguments, the is required." 1>&2 @@ -365,8 +370,6 @@ attach_jvm() echo "Attaching to ${TARGET_PID} using version ${1}..." - echo ${ARTHAS_OPTS} - if [ ${TARGET_IP} = ${DEFAULT_TARGET_IP} ]; then ${JAVA_HOME}/bin/java \ ${ARTHAS_OPTS} ${BOOT_CLASSPATH} ${JVM_OPTS} \