diff --git a/src/main/java/com/beust/jcommander/JCommander.java b/src/main/java/com/beust/jcommander/JCommander.java index f988bde99..93ed0a478 100644 --- a/src/main/java/com/beust/jcommander/JCommander.java +++ b/src/main/java/com/beust/jcommander/JCommander.java @@ -435,8 +435,13 @@ private String[] expandArgs(String[] originalArgv) { for (String arg : originalArgv) { if (arg.startsWith("@") && options.expandAtSign) { - String fileName = arg.substring(1); - vResult1.addAll(readFile(fileName)); + if(arg.startsWith("@/")){ + List expanded = expandDynamicArg(arg.substring(2,arg.length())); + vResult1.addAll(expanded); + }else { + String fileName = arg.substring(1); + vResult1.addAll(readFile(fileName)); + } } else { List expanded = expandDynamicArg(arg); vResult1.addAll(expanded); diff --git a/src/test/java/com/beust/jcommander/JCommanderTest.java b/src/test/java/com/beust/jcommander/JCommanderTest.java index a9360ea08..4307b2510 100644 --- a/src/test/java/com/beust/jcommander/JCommanderTest.java +++ b/src/test/java/com/beust/jcommander/JCommanderTest.java @@ -1433,4 +1433,34 @@ class Args { public static void main(String[] args) { new JCommanderTest().trimTest(); } + + @Test(expectedExceptions = java.nio.file.NoSuchFileException.class) + public void syntaxTest_1() + { + class Args{ + @Parameter(names = "-password",description = "parameter starts with @") + public String x = "password"; + } + Args args = new Args(); + JCommander.newBuilder() + .addObject(args) + .build() + .parse("-password","@X"); + Assert.assertEquals("@X", args.x); + } + + @Test + public void syntaxTest_2() + { + class Args{ + @Parameter(names = "-password",description = "parameter starts with @") + public String x = "password"; + } + Args args = new Args(); + JCommander.newBuilder() + .addObject(args) + .build() + .parse("-password","@/@X"); + Assert.assertEquals("@X", args.x); + } }