rvesse / airline

Java annotation-based framework for parsing Git like command line structures with deep extensibility
https://rvesse.github.io/airline/
Apache License 2.0
131 stars 20 forks source link

Passing strings with whitespaces #61

Closed santifa closed 7 years ago

santifa commented 7 years ago

Hi folks,

I just run into a problem that I want to pass file names with whitespaces to a program. I tried different methods to represent them as single string with either of " ' \. Is there a way the parser accepts escaped or quoted arguments as single input value and not multiple ones?

Best regards

rvesse commented 7 years ago

It is hard to say without you providing an example that demonstrates the problem.

Typically Airline is invoked on the arguments provided to the main(String[] args) method of an application. That is invoked by the JVM which will be invoked by your platforms shell. Therefore the details of how the original inputs are broken up into individual tokens will very much depend upon your platform and shell.

Assuming a *nix type platform and a Bash Shell then enclosing arguments in " or escaping whitespace with \ should be sufficient.

Please note that if you are using a script to invoke your application as opposed to invoking the JVM directly then you need to make sure that you pass arguments to the JVM without shell interpretation or expansion. For Bash this means using "$@" to pass through arguments.

santifa commented 7 years ago

Thanks for your help.

We use your program under *nix and windows from the cli as well as a jar file. By further investigations I found that the problem is nested within the filesystem handling done by java. For example a file name with spaces is passed as an argument and correctly escaped, but the different classes File|Path|URL|URI handles them differently which lead to different escape sequences (e.g %20 for a space character). So a file is correctly specified and present in the filesystem but can not found by the jvm since it assumes a escape sequence is part of the file name.

I think this issue can be closed.