Re: another command line parm puzzle.



In article <87bp44pr14cahlh13itqgn8q61v5tmb7rp@xxxxxxx>,
Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx> wrote:

On Sun, 08 Jun 2008 12:17:03 GMT, Roedy Green
<see_website@xxxxxxxxxxxxxxxxxxxx> wrote, quoted or indirectly quoted
someone who said :

But if I put something more complicated like:

java com.mindprod.example.TestParms
"/dp/([0-9A-Z]+)(/ref=[0-9a-z_]+)?\"\>Kindle"

Then there is no output because the > is treated as a redirection.

The roots of the problem are two:

1. the people who write command processors are tinkerers. They invent
syntactic kludges as needed. There is no uniform scheme to pass
arbitrary characters as a parm.

2. after the parm passes through the command processor, Java runtime
has yet another whack at it. It removes surrounding quotes, and can
even break a single parm into multiple ones if it contains a quote.

I don't think either of them ever though about the problem of trying
to pass a parm containing the kitchen sink (e.g. a regex).

Thompson, Bourne, Korn, Aho, Weinberger, Kernighan & Wall tinkerers?
Sure, why not! If thy command processor offends thee, download another
one:-) Most have some way to quote or escape special characters.

import java.io.*;
public class Grep {
public static void main(String[] args) throws IOException {
String re = args[0];
String line;
BufferedReader in = new BufferedReader(new FileReader(args[1]));
while (true) {
line = in.readLine();
if (line == null) break;
if (line.matches(re)) System.out.println(line);
}
}
}

Q. What unusual word has three "u"s and end with "y"?

$ java Grep "^.*u.?u.?u.*y$" /usr/share/dict/words
unusually

Of course, in a make file, you'd have to escape the $:

java Grep "u.?u.?u.*y$$" /usr/share/dict/words

John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
.



Relevant Pages

  • Re: Problems accessing dot net web service from java client
    ... I see many subtle differences in the wdsl files between a Sun site and a dot ... web Service experience feels like taking this on, ... As an aside, if I point the java client to a NON web service, it gives the ... "David Laub" wrote in message ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: A few questions about scaling transforms and clipping
    ... Knute Johnson wrote: ... very well in Java. ... All my experience is with TrueType on a Windows machine. ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.lang.java.gui)
  • Re: AppleCommander 1.3.5
    ... Java package, you'd do something like this from the command line: ... Please don't take me the wrong way, when I did try the GUI version, ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.sys.apple2.programmer)
  • Re: recreating timesharing IO
    ... and an event listener that would do a ... Most Java GUI programs don't care; ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.lang.java.gui)
  • Re: another command line parm puzzle.
    ... the people who write command processors are tinkerers. ... arbitrary characters as a parm. ... after the parm passes through the command processor, Java runtime ... It removes surrounding quotes, and can ...
    (comp.lang.java.help)