Fork me on GitHub
#clj-on-windows2020-06-11
>
borkdude18:06:41

According to stackoverflow something like this should store the output of clojure into the variable $x:

$x=(clojure -Spath -Sdeps '{:deps {org.clojure/data.zip {:mvn/version \"1.0.0\"}}}') | Out-String                          
(PowerShell). Why doesn't it work?

borkdude18:06:37

Maybe it's an issue with clojure:

$x=(echo "hello") | Out-String 
echo $x
"hello"

Alex Miller (Clojure team)19:06:19

I notice the powershell impl does Write-Host $CP, not sure if that should be Write-Out ?

borkdude19:06:13

it probably should, although I'm not a PS expert

Alex Miller (Clojure team)19:06:24

from some googling, I think so

Alex Miller (Clojure team)19:06:53

this kind of thing works in the *nix clojure

borkdude19:06:32

I use it all the time

Alex Miller (Clojure team)19:06:40

I fixed that and another case in -Sdescribe

Alex Miller (Clojure team)19:06:07

Write-Host is now only used for purely out of band informational messages

borkdude19:06:24

is Write-Host the stderr of PS?

Alex Miller (Clojure team)19:06:33

no, there is Write-Error too

Alex Miller (Clojure team)19:06:44

Write-Host truly only writes to the host and does write to out or err

Alex Miller (Clojure team)19:06:19

terminal is seeing all of them, but matters when pipelining

borkdude19:06:07

thanks for fixing

Alex Miller (Clojure team)19:06:19

I've got some pending minor fixes in tda, let me release that and then I'll push a new dev release of clj stuff

borkdude20:06:34

TIL that this "just works" on Windows:

user=> (require '[ :as io])
nil
user=> (io/file "src" "babashka/main.clj")
#object[java.io.File 0x722c07fa "src\\babashka\\main.clj"]

borkdude20:06:50

so you don't have to use the platform specific file separator there

seancorfield21:06:26

Yeah, but given that all the file APIs return \ in them, your code still needs to deal with both 😞

borkdude21:06:11

in my case I was scanning directories and .jar files for existing entries, so I can get away with only using one suffix string

borkdude21:06:37

you would maybe say: but Java already has something for this, it's called URLClassLoader or something. yeah, I tried, but GraalVM doesn't support this class because they can't dynamically load classes. it still would have been useful for just finding stuff, but ok

borkdude21:06:09

this worked ok for months, but now someone on Windows complained they couldn't load a library from a .jar file. turned out I was overcorrecting the path using a Windows-specific backwards slash when searching a jar file