[racket] Environment variables in paths
> Can't you write
> (build-path (getenv "WORKSPACE") ....)
The paths are command-line arguments and the tool is run in multiple
places. When I run it locally I don't use environment variables, but it's
also used as a script that's run on Jenkins after a project builds, and
Jenkins defines the workspace variable.
I ended up just making a method that checks if the first path element
starts with a $ and doing exactly what you said, but I was just hoping
there was something already built in.
> Could you push things through a call-out to 'system' with the 'echo'
program?
I'm just copying a file, so I could use system to copy the file instead of
Racket's copy-file, and that would take care of the environment stuff.
That's probably better than my solution.
It would be nice to have a flag or something that tells a path function to
resolve environment variables, but it's probably not a common enough case
to merit an extra api function.
Thanks for the suggestions.
On Fri, Sep 28, 2012 at 4:32 PM, Jay McCarthy <jay.mccarthy at gmail.com>wrote:
> Could you push things through a call-out to 'system' with the 'echo'
> program?
>
> On Fri, Sep 28, 2012 at 3:36 PM, Laurent <laurent.orseau at gmail.com> wrote:
> > Can't you write
> > (build-path (getenv "WORKSPACE") ....)
> > ?
> >
> > Laurent
> >
> > On Fri, Sep 28, 2012 at 11:30 PM, Nick Shelley <nickmshelley at gmail.com>
> > wrote:
> >>
> >> I can't seem to find a path function that deals with environment
> >> variables. Is there some variant of cleanse-path that resolves
> environment
> >> variables first?
> >>
> >> Concretely, I have an environment variable $WORKSPACE that tells where
> I'm
> >> operating from. The result of (getenv "WORKSPACE") is the correct
> absolute
> >> path, but (build-path "$WORKSPACE" ...) doesn't resolve the variable,
> so my
> >> filesystem commands are failing.
> >>
> >> Thanks.
> >>
> >> ____________________
> >> Racket Users list:
> >> http://lists.racket-lang.org/users
> >>
> >
> >
> > ____________________
> > Racket Users list:
> > http://lists.racket-lang.org/users
> >
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://faculty.cs.byu.edu/~jay
>
> "The glory of God is Intelligence" - D&C 93
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120928/970cdeb0/attachment.html>