Summary

shell-variable in egg-compile should quote environment variables

Metadata

Description

Without quoting shell variables, install scripts end up with commands like

 mkdir -p ${DESTDIR}'/home/mario/local/chicken-head/lib/chicken/11'

If DESTDIR} happens to contain a space, the command above will not do what it is expected to do.

Double-quoting shell variables on Unix systems is not harmful, as far as I can tell. I have no clue about Windows.

At the moment, shell-variable seems to be only applied to DESTDIR.

The following patch would improve the situation on Unix:

 diff --git a/egg-compile.scm b/egg-compile.scm
 index 4a72d5d0..e6be5d1d 100644
 --- a/egg-compile.scm
 +++ b/egg-compile.scm
 @@ -1227,7 +1227,7 @@ EOF
 
  (define (shell-variable var platform)
    (case platform
 -    ((unix) (string-append "${" var "}"))
 +    ((unix) (string-append "\"${" var "}\""))
      ((windows) (string-append "%" var "%"))))
 
  ;; NOTE `cmd' must already be quoted for shell

Changes and comments

[2020-03-09 21:32:38 UTC] wasamasa wrote:

You'll need to use double quotes on Windows as well, see https://ss64.com/nt/syntax-esc.html for the finer details.

[2021-04-10 01:51:56 UTC] evhan changed status from new to assigned

[2021-04-10 01:51:56 UTC] evhan set owner to evhan

[2021-04-10 01:51:56 UTC] evhan wrote:

This looks easy enough.

[2021-04-11 19:58:22 UTC] wasamasa wrote:

Regarding the double-quoting problem, yes, it's an issue on Windows, see https://bugs.call-cc.org/ticket/1727#comment:3 for my findings on the topic. A variable must be set correctly and assumed that it doesn't contain any unintended quotes.

[2021-05-20 21:18:11 UTC] mario wrote:

Fix for unix has been applied (f9a6dd4472bf137bdebd1613e302f1638305b1b9). We still have the issue on Windows.

[2021-05-20 21:23:10 UTC] mario changed milestone from 5.3 to 5.4

[2023-11-06 22:08:50 UTC] felix changed milestone from 5.4 to someday