Re: [RFC] Let "gcore" command accept a suffix argument

Hui Zhu
2010-01-09T15:18:10Z

Sorry Joel, I didn't write anything about the doc in prev mail because
I want write a special mail for it.

The current eval doesn't like shell. It just use " point out the simple string.
And if the string is outside out ", eval will try to convert it to val.
The special chat is " and \
If want add " in string. Use \"
If we want add \ in string. Use \\
For example:
eval "echo \""$a++"\""

"echo \"" and "\"" is simple string.
$a++ is val.

I know you want eval more like a language, but we already have python
support. So I suggest we use a simple eval.

On Sat, Jan 9, 2010 at 18:55, Joel Brobecker <brobecker@adacore.com> wrote:
>> This value will be convert to string and  execute_command (cmd,
>> from_tty); will use it.
>
> Which parts of the argument will be expanded. To take another language
> as an example, let's have a look at what a POSIX shell does:
>
>        echo "1 $foo 2"
>
> In double-quoted strings, the dollar sign has a the usual special
> meaning introducing parameter expansion. As a result, if our
> parameter "foo" was set to "bar",  the final value for the string above
> would be "1 bar 2".
>
> What I would like from you is a formal description of what your
> command does. "This value will be convert to string" is too vague.
> How will the conversion be done, and which parts of the string will
> be evaluated, and which parts won't?
>
> Intuitively, I think that you want to do the same as posix shells.
> In other words, if I borrow and adjust part of the POSIX shell language
> standard from the opengroup:
>
> | Enclosing characters in double-quotes ( "" ) shall preserve the literal
> | value of all characters within the double-quotes, with the exception of
> | the characters dollar sign, and backslash, as follows:
> |
> | $   The dollar sign shall retain its special meaning introducing
> |     parameter expansion
> |
> | \   The backslash shall retain its special meaning as an escape character
> |     only when followed by one of the following characters:
> |
> |         $   "   \   <newline>
>
> The issue I'm having, which is leading to this discussion about
> the semantics of your command, is that I do not think that the
> implementation that you chose follows the semantics above.
>
>> value_print print the value VAL in C-ish syntax on stream STREAM
>> according to OPTIONS.
>> But cannot find a example how to do it, could you help me with it?
>
> In fact, it will print the value in the syntax of the current language.
> I will fix the comment.
>
> What you need to do, in order to convert your value into a string,
> is create a memory ui_file, call value_print with your value and
> the memory ui_file, and then extract the contents of your ui_file
> as a string. See mem_fileopen and ui_file_xstrdup.
>

I got it. Thanks.

Best regards,
Hui