Re: Passing tab char in command line




"Oliver Wong" <owong@xxxxxxxxxxxxxx> wrote in message
news:cskfg.235$I61.27@xxxxxxxxxxx

"alejandrina" <apattin@xxxxxxxxx> wrote in message
news:1149096110.999422.142430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,

I want to pass a tab character as a command line parameter. Ihave this
statement to extract a char from the string:

char delim = args[0].charAt(0);

The problem is how do you write the command line? I've tried all of
these:

java testTab "\t"
java testTab "\\t"
java testTab \t
java testTab \\t
java testTab "\u0009"
java testTab \u0009

none work. "delim" above never gets the right character. Interestingly,
when I submit

java testTab "\u0009" or
java testTab "\\t"


args[0] contains a string of length = 2, the first character being "\"
and the second is the tab. Obviously, the parser feels the need to
"escape" my backslash character. How do you disable this behavior?

When you type things "at the command line", you're actually giving
input to a program which is typically called a "shell". On Windows XP, for
example, most people use the shell known as "cmd.exe". On Linux, it might
be bash, or csh or some other shell.

Each shell has its own rules about what escaping and/or processing it
does on the input.

Obviously, the shell you're using chooses not to replace \t with a tab
character, though it does seem to be replacine two-character substring
"\\" with the single character substring "\".

Read the documentation for your shell to find out what escaping
facilities it provides, and how you can coax it into invoke the java
program with the tab as one of the parameters.

- Oliver
And you might even try typing a double-quote,
followed by typing the tab key, and another double quote.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project


.



Relevant Pages

  • Re: Passing tab char in command line
    ... I want to pass a tab character as a command line parameter. ... On Windows XP, for example, most people use the shell known as "cmd.exe". ...
    (comp.lang.java.programmer)
  • Re: tab character in MSH ?
    ... Is it possible to make MSH differentiate between a pasted and a typed ... I often debug snippets of shell code by having ... common indentation character should not turn into a ... Tab is *very* commonly used as a completion character almost everywhere, ...
    (microsoft.public.windows.server.scripting)
  • Re: Passing tab char in command line
    ... I want to pass a tab character as a command line parameter. ...
    (comp.lang.java.programmer)
  • Re: Sed substitution of metacharacters in regex
    ... The tabulation character may not be printable, ... is a valid command. ... If you have troubles entering a <Tab> character in your shell, ...
    (comp.unix.shell)
  • Re: Formatting index entries
    ... replace each space with a tab character ... Copy the whole cell ... use Edit>Replace to replace every tab with a space. ... you want to rip all the Index tags out of the main document. ...
    (microsoft.public.mac.office.word)