On Tue, 18 Jul 2000, Shaul Karl wrote:

> Isn't there a way to prevent the shell from removing the quotes? Perhaps with 
> a more complicated structure of single and double quotes in the definition of 
> ARGUMENTS?

there is, by using backslash cahracters up to the number required by your
specific case. what happens is that at each evaluation of the string,
another expansion is performed. in the first expansion, your single quotes
are removed (that is, inside the executin of the 'echo' command). in the
second expansion (when executing the output of the echo command) your
double quotes are removed, and thus your program receives each word on the
command line as a different argument. what you need to do is type \"
instead of " (that is backslash+quotes instead of quotes).

the rule with any scripting language in this case is: when the output
looses quotes and backslahses due to expansion, ifnd out how many times
this translation is performed, and add enough quoting to "save" your
quotes and/or backslashes till the right time.

i usually play with such arguments until it starts working, and then do
not touch it. this phenomena happens with al scripting languages i have
see so far (sh, csh, perl, tcl. note lack of python here - never wrote
pythn scripts, only read a few).

guy

> BTW: ps does not show the quotation:
> 
> [01:25:29 /tmp]# ps axf |grep powercom | grep -v grep
> 8739 pts/9    S      0:00 powercom -m Advice Partner/King PR750 -s 00131581 
> /dev/ttyS1

this is because the quotes are striped by the shell before sending the
parameters to the command. if you'll check the program through a debugger,
you'll see that argv[1] contains 'powercom', argv[2] contains '-m',
argv[3] contains 'Advice Partner/King PR750', argv[4] contains '-s' and so
on. read the shell's source code for more info.


guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to