1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Literal tab character

Discussion in 'Support' started by nickles, Oct 27, 2011.

  1. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    How would I accomplish the following in TCC (taken from bash)?

    Code:
    sqlite3 --separator '${\t}' SOME_DATABASE < SOME_SCRIPT
    The problem is the translation of '${\t}' which is required to result in the a LITERAL (0x9) tab character embedded in single quotes. In a first (naive?) attempt I tried to translate this into:

    Code:
    sqlite3 --separator '^t' ...
    which - according to the help file should result in a literal tab character being inserted for ^t. As you will guess, this failed (like other attempts using "^t", `^t`, etc).

    nickles
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    ^T works for me, inserting a tab character in the command line.

    Is it possible the Windows port of your program is actually expecting a \T combination?
     
  3. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    Hi Charles,

    please try the following:

    works, separator is 'x'; but

    results in

    nickles
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    Either way, it's an unknown command on my system. But if I

    Code:
    echo sqlite3 -separator '^t' | list /x
    
    then I do see the 09 in the output.

    Have you tried just passing \T ?
     
  5. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    Hi Charles,

    it indeed seems to be a problem with the console or sqlite3 itself. Tried the command from a batch file (verifying that there really was a 0x9 between the single quotes) and it didn't work neither from cmd.exe nor from tcc.exe! Weird...

    Thanks for your help!

    nickles
     
  6. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    560
    Likes Received:
    8
    How about ...
    Code:
    sqlite3 -separator '^^t' "%FIX%\cookies.sqlite" "SELECT host FROM moz_cookies LIMIT 1;"
     
  7. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    No, unfortunately not working; results in ".forrst.com'^t'.forrst.com".

    Thanks!

    nickles
     
  8. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,179
    Likes Received:
    11
    The parsing for the shell does this to parse the separator command line
    switch:

    }else if( strcmp(z,"-separator")==0 ){
    i++;
    if(i>=argc){
    fprintf(stderr,"%s: Error: missing argument for option: %s\n",
    Argv0, z);
    fprintf(stderr,"Use -help for a list of options.\n");
    return 1;
    }
    sqlite3_snprintf(sizeof(data.separator), data.separator,
    "%.*s",(int)sizeof(data.separator)-1,argv);

    -Scott

    nickles <> wrote on 10/27/2011 04:15:54 PM:


     
  9. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,179
    Likes Received:
    11
    What happens if you put the tab char in double quotes?

    -Scott

    samintz <> wrote on 10/27/2011 05:15:10 PM:




     
  10. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,794
    Likes Received:
    29
    I haven't followed this thread carefully. Have you tried %@CHAR[9] on the
    command line? ... or **really** put a TAB there with Alt-0255 followed by the
    tab key?
     
  11. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    Hi samintz,

    the following works:(!)

    sqlite3 -separator "literal_tab_as_pasted_from_an_editor" ...

    These do not:

    sqlite3 -separator "^t" ...
    sqlite3 -separator "\t" ...
    sqlite3 -separator 'literal...' ...
    sqlite3 -separator `literal...` ...

    Thanks!

    nickles
     
  12. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    @vefatica

    Sorry, overread your answer.

    The following also works:

    sqlite3 -separator "%@char[9]" ...

    Interestingly ... "^t" doesn't work though it's supposed to according to the docs.

    Thanks!

    nickles
     
  13. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,179
    Likes Received:
    11
    I suspect then, that Vince's suggestion of using "%@char[9]" would work as
    well as the literal tab suggestion with Alt-0255<TAB>

    -Scott



    Hi samintz,

    the following works!)

    sqlite3 -separator "literal_tab_as_pasted_from_an_editor" ...

    These do not:

    sqlite3 -separator "^t" ...
    sqlite3 -separator "\t" ...
    sqlite3 -separator 'literal...' ...
    sqlite3 -separator `literal...` ...

    Thanks!

    nickles
     
  14. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,794
    Likes Received:
    29
    On Thu, 27 Oct 2011 17:47:02 -0400, nickles <> wrote:

    |Interestingly ... "^t" doesn't work though it's supposed to according to the docs.

    Although TCC "recognizes" ^t (et al. (help)) I don't think it would be wise to
    translate it in the args to other EXEs. The caret has a special meaning to many
    text utilities accepting regular expressions.
     
  15. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    Expansion of escape characters is done long before the external program is launched. I think the real issue is that it doesn't happen between double quotes -- I don't know why not, but there's probably some good reason.
     
  16. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,732
    Likes Received:
    81
    Whenever something doesn't make sense, it's a pretty good bet that the
    reason is "CMD compatibility".

    And so it is with this one.
     
  17. nikbackm

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    1
    :)

    What is CMD's excuse then?

    Maybe COMMAND.COM compability?
     
  18. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,732
    Likes Received:
    81
    There was a time when I tried to divine the intention behind CMD's syntax. But it made me dazed, confused, and ... uhhh ... what was I saying?
     
  19. DMcCunney

    Joined:
    Jun 7, 2008
    Messages:
    96
    Likes Received:
    3
    On Fri, Oct 28, 2011 at 2:48 PM, rconn <> wrote:

    I just assume that very few Windows users use CMD, so it has a low
    priority in MS, and gets assigned to the less experienced developers.
    A lot of the additions to NT CMD looked like a response to what you
    introduced in 4DOS. But the syntax feels a lot like hanging a bag on
    the side of the box, because doing it right is more trouble than they
    felt like taking.


    _____
    Dennis
     
  20. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    No; COMMAND.COM never had escapes.

    Perhaps the idea was that double-quotes are often used around filenames, and a filename is more likely to contain a caret than a control character -- though either one sounds like a Bad Plan to me.
     
  21. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,794
    Likes Received:
    29
    On Fri, 28 Oct 2011 15:25:28 -0400, Charles Dye <> wrote:

    |Perhaps the idea was that double-quotes are often used around filenames, and a filename is more likely to contain a caret than a control character -- though either one sounds like a Bad Plan to me.

    Isn't it simply not wanting to mess with the arguments a user wants to give to
    another EXE. How could you use a regular expression (grep, sed, ...) containing
    the common and useful "[^t]" if some command interpreter were turning it into
    something else?
     
  22. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    I think you're right; that makes more sense than my theory.
     

Share This Page