Re: A Tricky quoting problem

From: Paul D. Smith (psmith_at_nortelnetworks.com)
Date: 05/30/04


Date: 30 May 2004 14:02:40 -0400


%% "Alon" <noSpam@hotmail.com> writes:

  a> I Have a quoting problem that I can't solve. I need to make double
  a> quote inside single quote inside double quotes.

  a> I'm trying to make a catXML alias that will display formatted XML
  a> files.

  a> The catXML script is ready and working (mixture of sed and awk) but
  a> now i'm trying to convert the script to alias.

  a> The following does not work:
  a> alias catXML "cat \!* | sed -e 's/[ ]*["][ ]*/ABC/g' "

  a> I want that eventually:
  a> catXML= cat \!* | sed -e 's/[ ]*["][ ]*/ABC/g'

  a> How do I do that?

How about, "use a better shell"? This is trivial in any shell with
reasonable and consistent quoting and command parsing rules.

  catXML () {
    cat "$@" | sed -e 's/[ ]*["][ ]*/ABC/g'
  }

%% Later:

>> unset backslash_quote
>> set backslash_quote ; alias catXML 'cat \!* | sed -e \'s/[ ]*["][ ]*/ABC/g\''

  a> [ ... doesn't work ... ]

Good grief. I rest my case.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@nortelnetworks.com>   HASMAT--HA Software Mthds & Tools
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.


Relevant Pages

  • Re: need simple A/D converter
    ... quote enough for the article to make sense. ... interface to Usenet; it's not Usenet itself. ... entire quote intact to demonstrate that it appears that Google has ... solved the quoting problem. ...
    (comp.arch.embedded)
  • Re: A Tricky quoting problem
    ... "Alon" wrote in message news: ... > I Have a quoting problem that I can't solve. ... > I need to make double quote inside single quote inside double quotes. ...
    (comp.unix.shell)
  • Re: For Loops and Space in Names, take 2
    ... But you probably should quote $1 because of this: ... Probably leaked from the mv command you're printing. ... knowledge of the shell. ... You could use it to generate your mv commands with echo ...
    (Fedora)
  • Re: how to set timeout for read command
    ... > The shell is asked to do a number of things. ... This could take a very long time if the remote machine is not ... > Line 7 kills off the background subshell, ... forward quote before (sleep.... ...
    (comp.unix.shell)
  • Re: yet another newbie question about quoting
    ... > I'm trying to understand how quoting (single and double quote) works ... > with bash. ... The 2nd one is correctly quoted - you want the Shell to see one string. ...
    (comp.unix.shell)