Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 66985 - env-update mangles env.d data containing quotes
Summary: env-update mangles env.d data containing quotes
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All All
: High blocker
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 58564
  Show dependency tree
 
Reported: 2004-10-10 08:55 UTC by Matthew Kennedy (RETIRED)
Modified: 2005-07-14 06:58 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
remove extra variable expansion (portage.diff,658 bytes, patch)
2005-05-13 19:37 UTC, erik quanstrom
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Kennedy (RETIRED) gentoo-dev 2004-10-10 08:55:21 UTC
Here's an example (which the next update for app-shells/scsh
exhibits):

In /etc/env.d/50scsh:

    SCSH_LIB_DIRS='"/usr/lib/scsh/modules/0.6" "/usr/lib/scsh" "."'

In /etc/profile.env after env-update has run:

    export SCSH_LIB_DIRS=''/usr/lib/scsh/modules/0.6 /usr/lib/scsh .''

Which of course fails with:

    -bash: export: `/usr/lib/scsh': not a valid identifier
    -bash: export: `.': not a valid identifier

Needs to be fixed.  The workaround is to "einfo" something like
"Sorry, env-update doesn't handle a corner case.  Please manually add
export SCSH_LIB_DIRS=''/usr/lib/scsh/modules/0.6 /usr/lib/scsh .'' to
your /etc/profile"... which is unprofessional of course.
Comment 1 Matthew Kennedy (RETIRED) gentoo-dev 2004-10-10 08:56:58 UTC
It might not be clear depending on what font you're using but the '' in

    export SCSH_LIB_DIRS=''/usr/lib/scsh/modules/0.6 /usr/lib/scsh .''

Is two (2) single quotes, NOT a double quote.
Comment 2 SpanKY gentoo-dev 2004-10-10 18:38:14 UTC
portage manages env-update
Comment 3 Nicholas Jones (RETIRED) gentoo-dev 2004-10-11 07:18:33 UTC
I'm going to guess this is csh?

This definately doesn't play well with bash.

Could you provide a rough outline of the meaning and how it is
supposed to result?
Comment 4 Matthew Kennedy (RETIRED) gentoo-dev 2004-10-18 12:19:21 UTC
Its not csh, its not even shell dependent.  The environment variable should 
*contain* several strings in double quotes, separated by white space.

ie. if you echo $SCSH_LIB_DIRS, then the following is the expected output:

    $ echo $SCSH_LIB_DIRS
    "/usr/lib/scsh/modules/0.6" "/usr/lib/scsh" "."
    $

The fact that these are paths in double quotes separated by space should not be 
interpretted by the bash.  (If you really want to know the reason, then 
app-shells/scsh scsh binary looks in that environment variable and calls the 
scheme reader function (which reads scheme expressions -- like "asdf" and '(a b c) are scheme expressions) in a loop until all scheme expressions have been 
read. Presumably this builds up a list of paths for it to search for libraries 
in.)
Comment 5 Matthew Kennedy (RETIRED) gentoo-dev 2004-10-18 12:28:01 UTC
I guess their algorithm for operating on the environment variable looks 
something like this:

(defun read-paths (stream)
  (let ((path (read stream)))
    (when path
      (cons path
	    (read-paths stream)))))

(with-input-from-string (stream (get-env "SCSH_LIB_DIRS"))
  (read-paths stream)) 

  => ("/usr/lib/scsh/modules/0.6" "/usr/lib/scsh" ".")

...excuse my broken scheme accent.
Comment 6 Matthew Kennedy (RETIRED) gentoo-dev 2004-12-01 21:05:34 UTC
Bug 58564 and bug 58565 on this.  I could incorporate the ebuild and eclass as is (ie. "please add some foo to your /etc/profile now because /etc/env.d is broken") but it really requires the /etc/env.d system to be a policy compliant port.
Comment 7 erik quanstrom 2005-05-13 19:37:24 UTC
Created attachment 58848 [details, diff]
remove extra variable expansion

the problem with the quoting is that the text is parsed twice:
once by getconfig() and once by varexpand(). i removed the varexpand(),
which seems to solve this problem. also, i was working on a file to
provide MAIL=$HOME/.maildir which required \\\$HOME to get the $ through.
the first pass turned \\ -> \ and \$ -> $ resulting in '\$HOME' which was
then reparsed into $HOME. without the removal of varexpand there appeared no
way to sneak a ' (so that $HOME could be evaluated by the shell on login) past 

env-update.
Comment 8 Jason Stubbs (RETIRED) gentoo-dev 2005-05-13 20:19:50 UTC
Yep. That makes a total of three varexpand calls per special - there's one in getconfig too.
Comment 9 Jason Stubbs (RETIRED) gentoo-dev 2005-07-14 05:48:01 UTC
Fixed on or before 2.0.51.22-r1 
Comment 10 Jason Stubbs (RETIRED) gentoo-dev 2005-07-14 06:58:44 UTC
Looking through the batch of bugs, I'm not sure that some of these are 
actually fixed in stable. Others, the requirements have possibly changed after 
the initial fix was committed. 
 
If you think this bug has been closed incorrectly, please reopen or ask that 
it be reopened.