andrewchambers / janet-sh

Shorthand shell like functions for janet.
82 stars 6 forks source link

How to use shell variables? #22

Closed MaxGyver83 closed 6 months ago

MaxGyver83 commented 6 months ago

This doesn't work as expected (by me):

repl:8:> (sh/$ echo $PWD)
$PWD

It behaves like echo '$PWD'. How can I run an echo "$PWD"?

ianthehenry commented 6 months ago

janet-sh isn't trying to fully emulate a shell, so lots of shell features like $variables, foo.{c,h} expansion, subshells etc aren't implemented. If you want to read the value of an environment variable, you can use regular (os/getenv "PWD"), and pass that off to janet-sh:

(sh/$ echo ,(os/getenv "PWD"))
MaxGyver83 commented 6 months ago

I see. Thank you for this clarification!