You can make a command with quoted `$` like this: `echo \$x` or `echo '$x'`.
On Wed, Nov 2, 2016 at 8:00 AM, Christian Theil Have < christiantheilh...@gmail.com> wrote: > Thank you for the responses and my apologies for not being entirely clear: > Actually, the $PATH variable was just to provide an example. I really did > want to construct a Cmd with an unquoted dollar in it. > The reason why I want do such a silly thing is that I have a toying with a > package (https://github.com/cth/QsubCmds.jl) which generates shell > scripts from Cmd's that are run through sun grid engine, so > since the commands are not executed by Julia anymore, but a shell, it > makes sense to allow interaction with shell variables. I do not know > whether there could be any other use case for this (probably not). > > I get if this is not possible for the reason that there is no shell to > expand variables when running Cmds from Julia, but I just wondered if there > are some escaping mechanism that makes it possible to construct such > commands. > > Best, > Christian > > > > Den onsdag den 2. november 2016 kl. 12.23.00 UTC+1 skrev Stefan Karpinski: >> >> I think that needs some additional parens: `echo $(ENV["PATH"])`. This is >> in fact, exactly what you need – Julia commands in backticks are not run by >> a shell so there is no shell to expand any environment variables, only >> Julia can expand them. >> >> On Wed, Nov 2, 2016 at 7:02 AM, Simon Byrne <simon...@gmail.com> wrote: >> >>> Perhaps not quite what you had in mind, but >>> >>> `echo $ENV["PATH"]` >>> >>> should work >>> >>> On Wednesday, 2 November 2016 10:43:47 UTC, Christian Theil Have wrote: >>>> >>>> Hi, >>>> >>>> I've been trying to create a shell command that refers to an >>>> environment variable, e.g., >>>> >>>> echo $PATH >>>> >>>> Julia will interpolate $ in shell commands in backticks to Julia >>>> variables, i.e., `echo $PATH`, will look for a Julia variable PATH. >>>> What can I do if I really want to insist having a shell command that >>>> includes a (non-quoted) dollar-sign? Currently, >>>> my workaround is `sh -c "echo \$PATH"`, but this is not really >>>> satisfactory. >>>> >>>> Best, >>>> Christian >>>> >>> >>