Fork me on GitHub

Not sure I would feel secure pushing dynamically generated JSON directly as an argument to a Clojure function on the command line. I would be much happier if the command pushed JSON to a file and then that filename passed as an argument to the Clojure function. As well as being simpler, it would also keep a separate record of what JSON was passed to the function. Or at least pass the generated JSON through a tool to convert to EDN safely and then pass as an argument. Adding an escape character / for certain argument values feels a bit cryptic in terms of usability, but admittedly I don't have any use cases that would take this approach anyway.


It's not just about JSON, it's about having to quote arguments if you just want the vanilla cmd line string in general. A workaround is to parse symbols and then convert them to strings again, but this can result in invalid symbol reads. Quoting in shells is just hard and also makes it a bit more verbose. Having a way to bypass this is imo useful. Having a less cryptic way: all for it! I'm curious about other alternatives :).


hmm… You can always use *command-line-args* but you’d probably want to switch from -X to -M for invocation in order to stop that parsing altogether. For the JSON case you’d almost certainly be better passing it via stdin or a file though. Regarding the separator / it also strikes me as confusing because it’s the unix path separator and iirc it used to be a /arg separator in DOS — not used Windows for over 20 years though, so no idea if that’s still relevant 😆


Introducing a special escape character to simplify escaping rules also feels like a bit of a contradiction


@borkdude: Also one question; in your JSON usecase how would such a thing know to escape strings in the JSON from both the clojure reader and the shell?


I definitely get the motivation for such a thing, I’m just not sure there’s going to be a good solution :thinking_face:


@rickmoynihan I know command-line-args and -M, that's what I've been recommending when people run into this, but some of the tooling went the -X route and even deprecated -M usage, so you will run into this no matter what.


yeah though arguably that’s a problem for the tools… I mean they should pick the flag/approach for the job.

Alex Miller (Clojure team)13:02:12

for me, the open question is whether this is something that should be annotated on the function or at the CLI


yeah I was thinking you’d want to opt certain keys out of the processing outside of this… perhaps as some kind of args data… maybe some kind of :tools.deps/dont-read #{:arg1 :arg2} structure??


in :exec-args though that might be a level too deep ??

Alex Miller (Clojure team)13:02:00

I was actually thinking about on the function itself, but that's another option

Alex Miller (Clojure team)13:02:25

it needs a design sheet to compare, I'll get around to it eventually


yeah though I recall a bunch of discussions from years back about how vars are overloaded etc 🙂


I'll document these alternatives in the issue


I think the var metadata approach is a nice one: then it will work regardless of configuration and it won't clutter the invocation


(defn foo
  {:tools.deps/exec-skip-edn-read #{:a}} 
  [{:keys [a b c]}]


I think the problem is that affordances of -X and build.clj are too good 🙂


which meant perhaps people switched from -M too soon… I speak as someone who doesn’t enjoy maintaining both -M and -X interfaces — but I can’t shake the fact that there are trade offs between them

Alex Miller (Clojure team)13:02:33

well, that's the first question :)

😆 1
Matheus Bernardes17:02:36

When I try to download all version of t.d.a returns nil, digging in the problem I saw that this is being responsible to the problem since it’s only matching versions starting with number and all the versions of starts with a letter v. Is it supposed to work like that or is it a bug?

Alex Miller (Clojure team)17:02:02

Maven version components are (usually) numbers

Alex Miller (Clojure team)17:02:31

Can you back up to what you're actually calling?

Matheus Bernardes17:02:59

clj -X:deps find-versions :lib

Alex Miller (Clojure team)18:02:23

That is definitely a presumption baked into that program. Can you put this in an question for me?