[GRASS-dev] Re: quotong in messages

Ivan Shmakov ivan at theory.asu.ru
Wed Mar 5 12:54:21 EST 2008


>>>>> Maciej Sieczka <tutey at o2.pl> writes:

 >>> It could very well be user error & bad memory on my behalf.

 >> It's probably so.  It seems that `!' cannot be granted its special
 >> meaning within the non-interactive Bash (even with explicit `set
 >> -H'.)

 >>> But regardless it can only be a good thing to '' quote !s.

 >> I guess there're enough scripts with unquoted `!' outside of GRASS,
 >> and I believe that the special treatment of `!' violates POSIX.  So,
 >> the only good thing for the user would be to fix the Shell.

 > So g.message manual is not correct:

 > Messges containing '!' and '$' must use single 'quotes' to avoid
 > unwanted shell translation.

 > It should be:

 > On the shell command line, messages containing '!' and '$' must use
 > single quotes to avoid unwanted shell translation of events and
 > variables. In shell scripts, both double and single quotes are
 > safe.

 > Right?

	Yes.  But, I'm doubt that the GRASS documentation is a good
	place to explain how to use the Shell language.

	Not to mention that the Shell quoting rules are specific to the
	Shell being used, and not to the `g.message' GRASS module.  (Or
	should the quoting be explained in, e. g., the `g.mlist'
	documentation as well?)

	Because of the above, may I suggest to use something like the
	following in the documentation?

    When using `g.message' from the Shell, it's advisable to single
    quote the messages that are to be printed literally.  It prevents a
    number of characters (most notably, space and the dollar sign `$')
    from being treated specifically by the Shell.

    When it's necessary to include, e. g., a variable's value as part of
    the message, the double quotes may be used, which do not deprive the
    dollar sign of its special meaning.

    While it's known that the interactive Bash instances may treat the
    exclamation mark `!' character specifically (making single quoting
    of it necessary), it shouldn't be the case for the non-interactive
    instances of Bash.

	As there're many other ways to do the quoting, e. g.:

   echo '$'"${price} per unit of \`foo'"

	I'd rather point the reader to the reference for the Shell being
	used.



More information about the grass-dev mailing list