Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

escapes getting into program

Oct
356
2
Greetings --

I am trying to tun gawk and getting a error --

the awk cmd is

awk `{ print $1}`

I used the ` char since the jpsoft doc note that the contents are pass
to the program as-is, but gawk generate an error message that ` is
invalid -- how is the ` getting into the gawk program
 
fpefpe wrote:
| Greetings --
|
| I am trying to tun gawk and getting a error --
|
| the awk cmd is
|
| awk `{ print $1}`
|
| I used the ` char since the jpsoft doc note that the contents are
| pass
| to the program as-is, but gawk generate an error message that ` is
| invalid -- how is the ` getting into the gawk program

Simple - the whole argument, include the ` character, is passed on. Unless
the command line includes one of the special characters that have
syntactical meaning to TCC you do not need any form of quoting.
--
HTH, Steve
 
I don't know what you're trying to accomplish. But this works for me:

awk -- "{ print $1 }"

awk -- "BEGIN { print \"Hello world\" }"

-Scott


fpefpe <> wrote on 05/04/2009 07:45:31 PM:


> Greetings --
>
> I am trying to tun gawk and getting a error --
>
> the awk cmd is
>
> awk `{ print $1}`
>
> I used the ` char since the jpsoft doc note that the contents are pass
> to the program as-is, but gawk generate an error message that ` is
> invalid -- how is the ` getting into the gawk program
>
>
>
>
 
On Mon, 04 May 2009 18:45:59 -0500, fpefpe <> wrote:

|the awk cmd is
|
|awk `{ print $1}`
|
|I used the ` char since the jpsoft doc note that the contents are pass
|to the program as-is, but gawk generate an error message that ` is
|invalid -- how is the ` getting into the gawk program

I can't explain it but I doubt they're being passed to awk (unless awk is
somehow special). TCC just doesn't do that. For example:

v:\> u:\EchoArgs.exe `{ print $1 }`
u:\EchoArgs.exe
{
print
$1
}

Have you perhaps used SETDOS to disable the back-quote?
--
- Vince
 
vefatica wrote:
| I can't explain it but I doubt they're being passed to awk (unless
| awk is somehow special). TCC just doesn't do that. For example:
|
| v:\> u:\EchoArgs.exe `{ print $1 }`
| u:\EchoArgs.exe
| {
| print
| $1
| }

That's not my observation. My 15-year old ANSI C program (text mode, of
course) argparse.exe reports with equivalent command line (identical command
tail):

Command tail: '{ print $1 }'
0 "C:\UTIL\ARGPARSE.EXE"
1 "'{"
2 "print"
3 "$1"
4 "}'"

Note that the backticks are part of the command tail and of the 1st and 4th
argument. All this with SETDOS reporting EXPANSION=0, i.e., nothing
disabled.
--
Steve
 
Steve Fabian wrote:

>
> vefatica wrote:
> | I can't explain it but I doubt they're being passed to awk (unless
> | awk is somehow special). TCC just doesn't do that. For example:
> |
> | v:\> u:\EchoArgs.exe `{ print $1 }`
> | u:\EchoArgs.exe
> | {
> | print
> | $1
> | }
>
> That's not my observation. My 15-year old ANSI C program (text mode, of
> course) argparse.exe reports with equivalent command line (identical
> command
> tail):
>
> Command tail: '{ print $1 }'
> 0 "C:\UTIL\ARGPARSE.EXE"
> 1 "'{"
> 2 "print"
> 3 "$1"
> 4 "}'"
>
> Note that the backticks are part of the command tail and of the 1st and
> 4th
> argument. All this with SETDOS reporting EXPANSION=0, i.e., nothing
> disabled.

But those are forward ticks, not backticks!

--
Howard
 
On Mon, 04 May 2009 20:15:55 -0500, Steve Fábián <> wrote:

|That's not my observation. My 15-year old ANSI C program (text mode, of
|course) argparse.exe reports with equivalent command line (identical command
|tail):
|
|Command tail: '{ print $1 }'
|0 "C:\UTIL\ARGPARSE.EXE"
|1 "'{"
|2 "print"
|3 "$1"
|4 "}'"
|
|Note that the backticks are part of the command tail and of the 1st and 4th
|argument. All this with SETDOS reporting EXPANSION=0, i.e., nothing
|disabled.

How can that be? 4NT/TCC never passed on back-quotes (to my knowledge). Here's
another test, using my 5-minute old test.exe:

g:\projects\test\release> type ..\test.cpp
#include <windows.h>
#include <stdio.h>

INT wmain ( INT argc, WCHAR **argv )
{
WCHAR *pszCommandLine = GetCommandLineW();
wprintf(L"%s\n", pszCommandLine);
return 0;
}
g:\projects\test\release> test.exe `{ foo }`
test.exe { foo }
--
- Vince
 
On Mon, 04 May 2009 18:45:59 -0500, fpefpe <> wrote:

|the awk cmd is
|
|awk `{ print $1}`
|
|I used the ` char since the jpsoft doc note that the contents are pass
|to the program as-is, but gawk generate an error message that ` is
|invalid -- how is the ` getting into the gawk program

I can't explain it but I doubt they're being passed to awk (unless awk is
somehow special). TCC just doesn't do that. For example:

v:\> u:\EchoArgs.exe `{ print $1 }`
u:\EchoArgs.exe
{
print
$1
}

Have you perhaps used SETDOS to disable the back-quote?
--
- Vince

Greetings --

No, I don't think that I turned of quoting with setdos.
I was trying to run gawk command using the back tick ` prevent the
command line from being process. I kept getting errors, so I wrote a simple C
program to echo the contents of the argv array passed into the program. In
addition, I also called the win/api "GetComamndLine" to get the complete command
line

If I am reading the doc correctly, the ` character when used to start and end an
argument, should be striped way and the text between them passed to the program
in the same way the ' work for unix shell.
From my simple program, that does not seem to be the case -- Did I miss read
the doc?

Thanks

Frank Esposito

Sample program output -->

Cmd line {args this is a `test`}
Args Count: 5

Argument(0) is {args}
Argument(1) is {this}
Argument(2) is {is}
Argument(3) is {a}
Argument(4) is {`test`}
 
Greetings --

No, I don't think that I turned of quoting with setdos.
I was trying to run gawk command using the back tick ` prevent the
command line from being process. I kept getting errors, so I wrote a simple C program to echo the contents of the argv array passed into the program. In addition, I also called the win/api "GetComamndLine" to get the complete command line

If I am reading the doc correctly, the ` character when used to start and end an argument, should be striped way and the text between them passed to the program in the same way the ' work for unix shell.
From my simple program, that does not seem to be the case -- Did I miss read the doc?

I don't know what's going on on your system, but on mine the backquotes definitely are stripped before a command is executed. What do you see when you do e.g.

Code:
echo `foo`

What does VER /R report?
 
On Fri, 15 May 2009 17:18:01 -0500, fpefpe <> wrote:

|Sample program output -->
|
|Cmd line {args this is a `test`}
|Args Count: 5
|
|Argument(0) is {args}
|Argument(1) is {this}
|Argument(2) is {is}
|Argument(3) is {a}
|Argument(4) is {`test`}

That's contrary to what I see (and contrary to the way 4NT/TCC has always
worked):

v:\> args this is a `test`
args
this
is
a
test

Are you talking about the backtick which is on the key just to the left of the
"1" key?
--
- Vince
 
Greetings --

I am trying to tun gawk and getting a error --

the awk cmd is

awk `{ print $1}`

I used the ` char since the jpsoft doc note that the contents are pass
to the program as-is, but gawk generate an error message that ` is
invalid -- how is the ` getting into the gawk program

I use gawk, but I assume that it's the same for awk.
First of all, use double quotes around your inline script:
awk "{ print $1}"
this works for me. The confusion starts when you need to use double quotes also inside the script. You need to use 3 double quotes to escape one single double quote in a gawk inline script, so:

awk "{ print """dollar1="""$1}"
this also works for me. Happy (g)awking

Years ago I read a post which stated that backtick processing is broken in awk for Windows. Now, I don't know what that really means, if awk actually makes up the backticks or what, but anyway I found the magic trick with the 3 double quotes and I'm happy.
 

Similar threads

Back
Top