From: Ben Soares Date: Fri, 19 May 2023 16:16:15 +0000 (+0100) Subject: JAL-4187 JAL-629 JAL-3830 Fix ArgParser to check for empty string argument. Fixed... X-Git-Tag: Release_2_11_4_0~311 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e646b3d29d6daad3c5c1391866b1bd5f4acd5fb2;p=jalview.git 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 --- 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}" +}