java - Is there any way to find out an argument passed to a jar was quoted? -
java - Is there any way to find out an argument passed to a jar was quoted? -
i'm trying pass number of arguments java application, parse them myself using intelligent parser doesn't rely on whitespace separate arguments. example:
/update source=foo func=(bar, foo ,foo,bar)this works nicely converting tokens , parse those. however, problem occurs when add:
path="./foo/bar/foo bar.txt"(note double space between foo , bar).
when utilize double quotes, argument passed single string, preserving double space. quotation marks removed though this:
path=./foo/bar/foo bar.txtwhich makes parser fail. when seek utilize other character utilize quotes, ', parser works fine shell passes string 2 separate strings, separated @ double space, hence lose info there 2 spaces there.
what can pass argument using double quotes maintain literal string representation, maintain info string quoted, without user having type weird constructions "'string'"? i'm using java, maybe there way entire line of arguments unparsed shell? or without quotes beingness removed?
btw, ran microsoft command line, haven't tried unix shell yet, might fail on single quotes read on interwebs
on windows command line (using cmd.exe), can escape double quotes \". example,
java myapp path=\"./foo/bar/foo bar.txt\" will result in
args[0] = path="./foo/bar/foo args[1] = bar.txt" while
java myapp path="\"./foo/bar/foo bar.txt\"" will give you
args[0] = path="./foo/bar/foo bar.txt" java shell arguments
Comments
Post a Comment