Patchwork fixinclude: shell-quote testing file

login
register
mail settings
Submitter Tristan Gingold
Date May 16, 2011, 1:15 p.m.
Message ID <965D691B-295D-4BF9-93DC-33B63B53634F@adacore.com>
Download mbox | patch
Permalink /patch/95749/
State New
Headers show

Comments

Tristan Gingold - May 16, 2011, 1:15 p.m.
Hi,

one of the main VMS include files has a dollar in its name (decc$types.h), which is not shell friendly.

As a consequence, when the name is reused by check.tpl to create a baseline file, it must be quoted.
This is what is implemented in this patch.

Tested by 'make check' in fixincludes/

Ok for trunk ?

Tristan.

fixincludes/
2011-05-16  Tristan Gingold  <gingold@adacore.com>

	* check.tpl: Shell-quote testing file.
Andreas Schwab - May 16, 2011, 1:26 p.m.
Tristan Gingold <gingold@adacore.com> writes:

> 2011-05-16  Tristan Gingold  <gingold@adacore.com>
>
> 	* check.tpl: Shell-quote testing file.
>
> diff --git a/fixincludes/check.tpl b/fixincludes/check.tpl
> index b239d8b..0f3937a 100644
> --- a/fixincludes/check.tpl
> +++ b/fixincludes/check.tpl
> @@ -87,7 +87,7 @@ FOR fix  =][=
>    ELSE   =]
>  cat >> [=
>      IF (exist? "files") =][=
> -      files[0] =][=
> +      (string-substitute (get "files[0]") "$" "\\$") =][=

If you want to reliably shell-quote the string you should use
raw-shell-str.

Andreas.
Bruce Korb - May 16, 2011, 1:33 p.m.
On Mon, May 16, 2011 at 6:15 AM, Tristan Gingold <gingold@adacore.com> wrote:
> Hi,
>
> one of the main VMS include files has a dollar in its name (decc$types.h), which is not shell friendly.
>
> As a consequence, when the name is reused by check.tpl to create a baseline file, must be quoted.

> Ok for trunk ?

> diff --git a/fixincludes/check.tpl b/fixincludes/check.tpl
> index b239d8b..0f3937a 100644
> --- a/fixincludes/check.tpl
> +++ b/fixincludes/check.tpl
> @@ -87,7 +87,7 @@ FOR fix  =][=
>   ELSE   =]
> -cat >> [=
> -   IF (exist? "files") =][=
> -      files[0] =][=
> -   ELSE =]testing.h[=
> -   ENDIF =] <<_HACK_EOF_

Easier would be to just single (apostrophe) quote the string:

  cat >> '[= (if (exist? "files") (get "files[0]") "testing.h")
            =]' <<_HACK_EOF_

Or, as Andreas said after I typed the above:)

  cat >> [= (raw-shell-str (if (exist? ...))) =] <<_HACK_EOF_
Tristan Gingold - May 16, 2011, 1:33 p.m.
On May 16, 2011, at 3:26 PM, Andreas Schwab wrote:

> Tristan Gingold <gingold@adacore.com> writes:
> 
>> 2011-05-16  Tristan Gingold  <gingold@adacore.com>
>> 
>> 	* check.tpl: Shell-quote testing file.
>> 
>> diff --git a/fixincludes/check.tpl b/fixincludes/check.tpl
>> index b239d8b..0f3937a 100644
>> --- a/fixincludes/check.tpl
>> +++ b/fixincludes/check.tpl
>> @@ -87,7 +87,7 @@ FOR fix  =][=
>>   ELSE   =]
>> cat >> [=
>>     IF (exist? "files") =][=
>> -      files[0] =][=
>> +      (string-substitute (get "files[0]") "$" "\\$") =][=
> 
> If you want to reliably shell-quote the string you should use
> raw-shell-str.

Works for me too.  Thanks.

Tristan.

Patch

diff --git a/fixincludes/check.tpl b/fixincludes/check.tpl
index b239d8b..0f3937a 100644
--- a/fixincludes/check.tpl
+++ b/fixincludes/check.tpl
@@ -87,7 +87,7 @@  FOR fix  =][=
   ELSE   =]
 cat >> [=
     IF (exist? "files") =][=
-      files[0] =][=
+      (string-substitute (get "files[0]") "$" "\\$") =][=
     ELSE =]testing.h[=
     ENDIF =] <<_HACK_EOF_