I wrote a script run.sh below to call the java class:
java -cp . Main $1 $2 $3 $4
Here is my java class (it just displays args):
public class Main {
public static void main(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
}
}
This works if I do not try to pass a parameter containing a space. For instance:
./run.sh This is "a test"
will display:
This
is
a
test
How can I change my shell script and / or change the syntax of the parameters to pass the parameter "test" unmodified?
source
share