Literal tab character

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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
 
#3
Hi Charles,

please try the following:

sqlite3 -separator 'x' "%FIX%\cookies.sqlite" "SELECT host FROM moz_cookies LIMIT 1;"
works, separator is 'x'; but

sqlite3 -separator '^t' "%FIX%\cookies.sqlite" "SELECT host FROM moz_cookies LIMIT 1;"
results in

sqlite3: Error: too many options: "SELECT host FROM moz_cookies LIMIT 1;"
Use -help for a list of options.
nickles
 
#5
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
How about ...
Code:
sqlite3 -separator '^^t' "%FIX%\cookies.sqlite" "SELECT host FROM moz_cookies LIMIT 1;"
 

samintz

Scott Mintz
May 20, 2008
1,203
11
Solon, OH, USA
#8
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:


> 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
>
>
 

samintz

Scott Mintz
May 20, 2008
1,203
11
Solon, OH, USA
#9
What happens if you put the tab char in double quotes?

-Scott

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

>
> 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:
>



> Quote:
>
> > 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
> >
> >
>
>
>
 
#11
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
@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
 

samintz

Scott Mintz
May 20, 2008
1,203
11
Solon, OH, USA
#13
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
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,383
39
Albuquerque, NM
prospero.unm.edu
#15
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.
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#16
> 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.
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.
 
Jun 7, 2008
96
3
#19
On Fri, Oct 28, 2011 at 2:48 PM, rconn <> wrote:

> ---Quote (Originally by nikbackm)---
> :)
> What is CMD's excuse then?
>
> Maybe COMMAND.COM compability?
> ---End Quote---
> There was a time when I tried to divine the intention behind CMD's syntax. *But it made it dazed, confused, and ... uhhh ... what was I saying?
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.


> Rex Conn
_____
Dennis
 
#21
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?