Quote variables correctly in case they contain special characters.
Use exec to run Java so the shell doesn't stick around.
--- lexparser-gui.sh.orig	2020-11-17 04:44:48.000000000 -0600
+++ lexparser-gui.sh	2021-11-24 10:25:58.000000000 -0600
@@ -8,6 +8,6 @@
 #
 
 
-scriptdir=`dirname $0`
+scriptdir="`dirname "$0"`"
 
-java -mx800m -cp "$scriptdir/*" edu.stanford.nlp.parser.ui.Parser $*
+exec java -mx800m -cp "$scriptdir/*" edu.stanford.nlp.parser.ui.Parser "$@"
--- lexparser-lang-train-test.sh.orig	2020-11-17 04:44:48.000000000 -0600
+++ lexparser-lang-train-test.sh	2021-11-24 10:25:35.000000000 -0600
@@ -12,7 +12,7 @@
 mem=6g
 
 if [ ! $# -ge 5 ]; then
-   echo Usage: `basename $0` lang len train_file test_file out_file features
+   echo Usage: "`basename "$0"`" lang len train_file test_file out_file features
    echo
    echo '  lang       : Language to parse (Arabic, English, Chinese, German, French)'
    echo '  len        : Maximum length of the sentences to parse'
@@ -27,24 +27,24 @@
 fi
 
 # Setup command-line options
-lang=$1
-len=$2
-train_path=$3
-test_file=$4
-out_file=$5
+lang="$1"
+len="$2"
+train_path="$3"
+test_file="$4"
+out_file="$5"
 
 shift 5
 
 # Language-specific configuration
-scriptdir=`dirname $0`
-echo $JAVANLP_HOME
-source $JAVANLP_HOME/projects/core/scripts/lexparser/lexparser_lang.def
+scriptdir="`dirname "$0"`"
+echo "$JAVANLP_HOME"
+source "$JAVANLP_HOME"/projects/core/scripts/lexparser/lexparser_lang.def
 
 # Setting classpath
 #CLASSPATH="$CLASSPATH":"$scriptdir/*"
 
 # Run the Stanford parser
-java -Xmx"$mem" -cp "$scriptdir/*:$CLASSPATH" edu.stanford.nlp.parser.lexparser.LexicalizedParser -maxLength "$len" \
--tLPP "$tlp" $lang_opts $* -writeOutputFiles \
+exec java -Xmx"$mem" -cp "$scriptdir/*:$CLASSPATH" edu.stanford.nlp.parser.lexparser.LexicalizedParser -maxLength "$len" \
+-tLPP "$tlp" $lang_opts "$@" -writeOutputFiles \
 -outputFilesExtension "$out_file"."$len".stp -outputFormat "penn" \
 -outputFormatOptions "removeTopBracket,includePunctuationDependencies" -train "$train_path" -test "$test_file"
--- lexparser-lang.sh.orig	2020-11-17 04:44:48.000000000 -0600
+++ lexparser-lang.sh	2021-11-24 10:24:38.000000000 -0600
@@ -14,7 +14,7 @@
 mem=3g
 
 if [ ! $# -ge 5 ]; then
-   echo Usage: `basename $0` lang len grammar out_file FILE...
+   echo Usage: "`basename "$0"`" lang len grammar out_file FILE...
    echo
    echo '  lang       : Language to parse (Arabic, English, Chinese, German, French)'
    echo '  len        : Maximum length of the sentences to parse'
@@ -30,22 +30,22 @@
 fi
 
 # Setup command-line options
-lang=$1
-len=$2
-grammar=$3
-out_file=$4
+lang="$1"
+len="$2"
+grammar="$3"
+out_file="$4"
 
 shift 4
 
 # Language-specific configuration
-scriptdir=`dirname $0`
-source $scriptdir/lexparser_lang.def
+scriptdir="`dirname "$0"`"
+source "$scriptdir"/lexparser_lang.def
 
 # Setting classpath
 CLASSPATH="$CLASSPATH":"$scriptdir/*"
 
 # Run the Stanford parser
-java -Xmx"$mem" -cp "$CLASSPATH" edu.stanford.nlp.parser.lexparser.LexicalizedParser -maxLength "$len" \
+exec java -Xmx"$mem" -cp "$CLASSPATH" edu.stanford.nlp.parser.lexparser.LexicalizedParser -maxLength "$len" \
 -tLPP "$tlp" $lang_opts $parse_opts -writeOutputFiles \
 -outputFilesExtension "$out_file"."$len".stp -outputFormat "penn" \
--outputFormatOptions "removeTopBracket,includePunctuationDependencies" -loadFromSerializedFile $grammar $*
+-outputFormatOptions "removeTopBracket,includePunctuationDependencies" -loadFromSerializedFile "$grammar" "$@"
--- lexparser.sh.orig	2020-11-17 04:44:48.000000000 -0600
+++ lexparser.sh	2021-11-24 10:22:41.000000000 -0600
@@ -3,12 +3,12 @@
 # Runs the English PCFG parser on one or more files, printing trees only
 
 if [ ! $# -ge 1 ]; then
-  echo Usage: `basename $0` 'file(s)'
+  echo Usage: "`basename "$0"`" 'file(s)'
   echo
   exit
 fi
 
-scriptdir=`dirname $0`
+scriptdir="`dirname "$0"`"
 
-java -mx150m -cp "$scriptdir/*:" edu.stanford.nlp.parser.lexparser.LexicalizedParser \
- -outputFormat "penn,typedDependencies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz $*
+exec java -mx150m -cp "$scriptdir/*:" edu.stanford.nlp.parser.lexparser.LexicalizedParser \
+ -outputFormat "penn,typedDependencies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz "$@"
