Literal tab character

Jun 24, 2008
223
0
Siegen, Germany
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
 
Jun 24, 2008
223
0
Siegen, Germany
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,689
106
Albuquerque, NM
prospero.unm.edu
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 ?
 
Jun 24, 2008
223
0
Siegen, Germany
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
 
Jan 19, 2011
614
15
Norman, OK
How about ...
Code:
sqlite3 -separator '^^t' "%FIX%\cookies.sqlite" "SELECT host FROM moz_cookies LIMIT 1;"
 

samintz

Scott Mintz
May 20, 2008
1,555
26
Solon, OH, USA
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,555
26
Solon, OH, USA
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
> >
> >
>
>
>
 
May 20, 2008
12,170
133
Syracuse, NY, USA
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?
 
Jun 24, 2008
223
0
Siegen, Germany
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
 
Jun 24, 2008
223
0
Siegen, Germany
@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,555
26
Solon, OH, USA
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
 
May 20, 2008
12,170
133
Syracuse, NY, USA
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
4,689
106
Albuquerque, NM
prospero.unm.edu
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
12,556
167
> 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.
 
May 30, 2008
238
2
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.

:)

What is CMD's excuse then?

Maybe COMMAND.COM compability?
 
Jun 7, 2008
101
5
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
 
May 20, 2008
12,170
133
Syracuse, NY, USA
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?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,689
106
Albuquerque, NM
prospero.unm.edu
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?

I think you're right; that makes more sense than my theory.
 

Similar threads