From e646b3d29d6daad3c5c1391866b1bd5f4acd5fb2 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 19 May 2023 17:16:15 +0100 Subject: [PATCH] JAL-4187 JAL-629 JAL-3830 Fix ArgParser to check for empty string argument. Fixed jalview.bin.Jalview to not like one empty argument. Fixed Powershell to not send a single empty argument --- src/jalview/bin/ArgsParser.java | 2 +- src/jalview/bin/Jalview.java | 5 ++++- utils/getdown/bin/jalview.ps1 | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/jalview/bin/ArgsParser.java b/src/jalview/bin/ArgsParser.java index c927f1f..ab33542 100644 --- a/src/jalview/bin/ArgsParser.java +++ b/src/jalview/bin/ArgsParser.java @@ -42,7 +42,7 @@ public class ArgsParser for (int i = 0; i < args.length; i++) { String arg = args[i].trim(); - if (arg.charAt(0) == '-') + if (arg.length() > 0 && arg.charAt(0) == '-') { arg = arg.substring(1); } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index fb31189..59382fd 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -302,8 +302,11 @@ public class Jalview System.setSecurityManager(null); } - if (args == null) + if (args == null || args.length == 0 || (args.length == 1 + && (args[0] == null || args[0].length() == 0))) + { args = new String[] {}; + } // get args needed before proper ArgParser bootstrapArgs = BootstrapArgs.getBootstrapArgs(args); diff --git a/utils/getdown/bin/jalview.ps1 b/utils/getdown/bin/jalview.ps1 index a5c0354..65998bc 100755 --- a/utils/getdown/bin/jalview.ps1 +++ b/utils/getdown/bin/jalview.ps1 @@ -79,6 +79,10 @@ $CLASSPATH = ( Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s* $CONSOLEWIDTH = $Host.UI.RawUI.WindowSize.Width # quote the args and the command (in case of spaces) with escape chars (`) and precede with & to indicate command not string -$myArgsString = '"' + $($myArgs -join '" "') + '"' -Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${myArgsString}" +if ( $myArgs.count -eq 0 ) { + Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher" +} else { + $myArgsString = '"' + $($myArgs -join '" "') + '"' + Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${myArgsString}" +} -- 1.7.10.2