remember user's working directory when script files are being loaded in 
execution mode


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8fd6dbbe
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8fd6dbbe
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8fd6dbbe

Branch: refs/heads/TINKERPOP-1602
Commit: 8fd6dbbe9cc0b98d124cd3fdf739377289300ce8
Parents: e80a4cd
Author: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Authored: Wed Jan 18 17:18:46 2017 +0100
Committer: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Committed: Wed Jan 18 17:18:46 2017 +0100

----------------------------------------------------------------------
 gremlin-console/src/main/bin/gremlin.sh                      | 4 +++-
 .../org/apache/tinkerpop/gremlin/console/Console.groovy      | 8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fd6dbbe/gremlin-console/src/main/bin/gremlin.sh
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/bin/gremlin.sh 
b/gremlin-console/src/main/bin/gremlin.sh
index 901610b..d8c94db 100755
--- a/gremlin-console/src/main/bin/gremlin.sh
+++ b/gremlin-console/src/main/bin/gremlin.sh
@@ -22,6 +22,8 @@
 set -e
 set -u
 
+USER_DIR=`pwd`
+
 cd $(dirname $0)
 DIR=`pwd`
 
@@ -90,7 +92,7 @@ while getopts ":l" opt; do
     esac
 done
 
-JAVA_OPTIONS="${JAVA_OPTIONS} 
-Dtinkerpop.ext=${USER_EXT_DIR:-${SYSTEM_EXT_DIR}} 
-Dlog4j.configuration=conf/log4j-console.properties 
-Dgremlin.log4j.level=$GREMLIN_LOG_LEVEL"
+JAVA_OPTIONS="${JAVA_OPTIONS} -Duser.working_dir=${USER_DIR} 
-Dtinkerpop.ext=${USER_EXT_DIR:-${SYSTEM_EXT_DIR}} 
-Dlog4j.configuration=conf/log4j-console.properties 
-Dgremlin.log4j.level=$GREMLIN_LOG_LEVEL"
 JAVA_OPTIONS=$(awk -v RS=' ' '!/^$/ {if (!x[$0]++) print}' <<< 
"${JAVA_OPTIONS}" | grep -v '^$' | paste -sd ' ' -)
 
 if [ -n "$SCRIPT_DEBUG" ]; then

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fd6dbbe/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index a2e518c..0788f42 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -378,7 +378,13 @@ class Console {
                 groovy.execute("args = []")
             }
 
-            final File file = new File(scriptFile)
+            File file = new File(scriptFile)
+            if (!file.exists() && !file.isAbsolute()) {
+                final String userWorkingDir = 
System.getProperty("user.working_dir");
+                if (userWorkingDir != null) {
+                    file = new File(userWorkingDir, scriptFile);
+                }
+            }
             int lineNumber = 0
             def lines = file.readLines()
             for (String line : lines) {

Reply via email to