dundalek / closh

Bash-like shell based on Clojure
Eclipse Public License 1.0
1.62k stars 66 forks source link

Figure out a way to splice in seq of arguments #127

Open dundalek opened 5 years ago

dundalek commented 5 years ago

So that arguments can be spliced instead of using workarounds like this:

(eval `(sh-str git status ~@flags > "/dev/null" | tail -n1))

After it might become:

(apply sh-str* (concat ["git" "status"] flags '["/dev/null" | tail -n1]))

Now that I see it.. it looks ugly too. So there may be even some better way.

dundalek commented 5 years ago

Maybe use metadata?

(sh-str git status ^:splice flags > "/dev/null" | tail -n1)
jeroenvandijk commented 5 years ago

In my opinion the apply version isn't that ugly. Especially since we would use it in scripts only.

Also it can be made slightly less ugly:

(apply sh-str* "git" "status" (concat flags '["/dev/null" | tail -n1]))

This might be uglier then the metadata option, for instance, but it would be easier to understand and reason about when you already have some experience in Clojure.