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

SignUp Now!

How to? Advanced quoting (for awk)

I'm trying to do this:

(from bash)

svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

As you can see, it uses advanced quoting, with multiple quotes, some of which are not really usable from Windows and TCC.

I'm sure I can do the same thing using simple TCC commands, but I'd like this to run first to be able to replicate the whole functionality.

I've gotten so far:

svn log -q | awk -F "|" "/^r/ {sub(\"^ \", \"\", $2); sub(\" $\", \"\", $2); print $2\" = \"$2\" ^<\"$2\"^>\"}"

This uses double quotes (because Windows, apparently) and \" to escape the quotes (I have no idea who does this - I'd guess TCC, but I've never seen escaping a quote with "\" before.

This unfortunately outputs
user = user ^<user^>
instead of
user = user <user>

If I don't use the escape for the redirection characters (< and >), I get

TCC: (Sys) Access is denied.

It would seem that you're damned if you do, damned if you don't with this.

I'll do it another way (I'm sure that @WORD will come in handy here), but the real question is, how can you pass the proper second parameter to awk?
Could you put the awk argument into a cmd file, and run awk -f something?

Many years ago, JPSoftware was pushing rexx for its advanced string handling.
Take a look at the various enable / disable codes of SETDOS /X. It might to the job for you; once you change the mask it is in effect for all commands until restored with another SETDOS command, and is part of the command stream. Also look at the TEXT / ENDTEXT block, which allows any character within the block, but is just text output to STDOUT (redirectable). The ECHOX command does the same for its parameters (i.e., the rest of its command line). If the command line is known when you write your batch file (i.e., not dynamically built) one of these techniques might be all you need. OTOH if you need to build the AWK command dynamically, Wendy's suggestion (build your command in a file) can help; the "binary buffer" method allows you to put anything in a file (albeit laboriously).