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

Joel Brobecker
2010-01-09T10:56:15Z

> 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.

--
Joel