clj-on-windows 2021-03-31

Is it too late for clj to default to strings instead of symbols? That would solve above issue. Even in bash I find this quoting of strings awkward.

@flyingpython This is an easy way to debug how args are parsed in a shell:

c:\Temp>bb -e "(prn *command-line-args*)" """foo"""
("\"foo\"")
bb.exe is babashka, a script interpreter for Clojure, but you can do this with normal Clojure as well. Apparently you have use use triple-quotes to preserve the quote in cmd.exe. I'll also try this in Powershell.

This worked for me in Powershell:

PS C:\Users\borkdude> bb -e "(prn *command-line-args*)" '\"foo\"'
("\"foo\"")

OK I'll give it a go thanks 🙂

pretty sure powershell uses backticks for escaping

`"mwebacpp"` 
might be ok?

Ah, how would I invoke this with Clojure? I tried clojure -M -e "(prn *command-line-args*)" '\"foo\"' but it doesn't work. I'm not that great at using commandline or Clojure yet 😅

@thheller doesn't work for me:

PS C:\Users\borkdude> bb -e "(prn *command-line-args*)" `"mwebacpp"`
>>  ^C
it launches me into a shell

@flyingpython What version of clojure do you have installed?

oh right I remember something. I do have some quoting for this in some shadow-cljs code. let me see

The latest 1.10.3

Ah OK so probably best to use Linux in WSL2 for Clojure like Sean recommended I think

@flyingpython I don't know why this doesn't work with normal Clojure:

$ clojure -M -e "(prn *command-line-args*)" -- 1 2 3
("1" "2" "3")
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-- (No such file or directory)
Maybe because it tries to execute something as a file, while it shouldn't. Maybe a bug @alexmiller?

Alex Miller (Clojure team) 2021-03-31T11:54:00.054Z

What are you expecting to happen? — is not something clojure.main understands

I would expect remaining args to be bound to *command-line-args* but maybe that's my wrong understanding

I'm sure you could argue otherwise

Alex Miller (Clojure team) 2021-03-31T13:03:17.054600Z

I think the clojure.main -h should lead you to not expect this to work

Alex Miller (Clojure team) 2021-03-31T13:07:07.054800Z

the command-line-args is designed to work with main-opts like -m or running a clj file, not to work with -e

Anyway, with babashka it works and it's fast so this might help for debugging

OK there was a Scoop bucket I saw for babashka so I'll grab that

set the channel topic: For those interested in making clj on Windows https://dev.clojure.org/jira/browse/TDEPS-67. Also see https://github.com/littleli/scoop-clojure.

yeah, I added that scoop to the topic now

Yeah the litteli scoop buckets are the ones I'm using to keep Java and Clojure up to date

Thanks for the help @borkdude and thanks for that github link with your powershell replaces @thheller - those should help 🙂

This is also a nice way of debugging:

PS>  bb -e "(map edn/read-string *command-line-args*)" '\"foo\"'
("foo")

"`\""two`\"""

looks fun 🙂 maybe there is a better way to do this though 🙂

I think mine looks simpler

ah, darn:

PS C:\Users\borkdude> bb -e "(map edn/read-string *command-line-args*)" '\"foo bar\"'
----- Error --------------------------------------------------------------------
Type:     java.lang.RuntimeException
Message:  EOF while reading string

(
it doesn't work with spaces in the string ;)

spaces also need to be escaped

so this is basically a nightmare when it comes to -X and strings. I'm not sure if trying to map EDN onto shells was such a great idea.

but for non-space strings, the solution in powershell is maybe doable... '\"foo\"', not pretty though

I would argue that writing -main functions and applying a sprinkle of tools.cli isn't going away, -X isn't always obviously better / less verbose, it's just less work to maintain a command line API

Ah OK thanks that read-string looks handy too, though I'll put a reminder only to use non-space strings

Hi guys, I'm having problems with a command on Powershell in Windows, I am using Sean Corfield's deps file with his :new alias to create a new project with the Luminus template but here is the code I entered and the output I get:

clojure -X:new :template luminus :name Rowan/guestbook :output '"mywebapp"' :args '["+h2" "+http-kit"]'
Downloading: luminus/lein-template/maven-metadata.xml from clojars
Unrecognized options: +h2, +http-kit
Supported options are: +sqlite, +hoplon, +kee-frame, +immutant, +datomic, +site, +undertow, +h2, +auth-jwe, +reitit, +reagent, +jetty, +cljs, +graphql, +service, +sassc, +oauth, +swagger, +servlet, +auth, +war, +http-kit, +expanded, +cucumber, +aleph, +mongodb, +basic, +postgres, +boot, +mysql, +re-frame, +kibit, +shadow-cljs
Sean says that command is working fine for him on Mac and Linux via WSL so just wondering if anyone might know why it's not working on Windows?

I think it's a quoting issue, around how :args gets passed through the underlying template, but I don't know the ins and outs of Windows' quoting quirks so I couldn't help Rowan...