Fork me on GitHub
#babashka
<
2022-12-07
>
annarcana00:12:14

I am finding that (shell {:continue true} ...) does not work for me. It still throws, and I can tell by the stack trace that it is indeed still calling check even though the docs and the code both say that's not supposed to happen. I am running the latest version of bb (v1.0.167), and the bundled babashka.process.

Bob B04:12:15

I think that the code in the process namespace was changed more recently than the latest release:

Babashka v1.0.167 REPL.
user=> (use '[babashka.process])
nil
user=> (shell {:continue true} "dir missingdir")
/usr/bin/dir: cannot access 'missingdir': No such file or directory
clojure.lang.ExceptionInfo [at <repl>:2:1]

Babashka v1.0.168-SNAPSHOT REPL.
user=> (use '[babashka.process])
nil
user=> (shell {:continue true} "dir missingdir")
/usr/bin/dir: cannot access 'missingdir': No such file or directory
{:proc #object[java.lang.ProcessImpl...
the shell function that's in the babashka.tasks ns does already 'work' (not throw) if the continue option is passed

👍 2
borkdude08:12:54

I'll make a new release today, because I can see how confusing this can be when reading the new process readme and trying out the latest bb

borkdude11:12:18

1.0.168 is now available

😎 1
annarcana16:12:07

Works now, thank you!

🎉 1
borkdude10:12:26

https://github.com/babashka/babashka: Native, fast starting Clojure interpreter for scripting 1.0.168 (2022-12-07) • loop*, fn* are now special forms and loop, fn, defn, defmacro, and and or are implemented as macros. This restores compatibility with https://github.com/borkdude/hyperfiddle-rcf • fs: don't touch dirs in split-ext • Update to babashka process to v0.4.13: support (process opts? & args) syntax everywhere • https://github.com/babashka/babashka/issues/1438: expose query-string and url-encode functions from org.httpkit.client (https://github.com/bobisageek) • Add java.util.InputMismatchException

😎 2
jeroenvandijk11:12:53

Nice! Maybe I’ll try to overwrite fn to see if we can include a recursion cap like in https://github.com/babashka/sci/issues/348

borkdude11:12:36

Go ahead :)

jeroenvandijk11:12:00

I think it will take me some time, but really cool that it is now possible (I think) without core changes

borkdude11:12:45

yes. rcf has a kind of tools.analyzer-like thing going on in their code which makes rewriting/instrumenting SCI code possible

👌 1
borkdude11:12:44

With a few hacks, I was able to make tools.analyzer work:

$ clojure -M:babashka/dev -Sdeps '{:paths ["src/main/clojure"] :deps {org.clojure/tools.analyzer.jvm {:mvn/version "RELEASE"}}}' -e "(require '[clojure.tools.analyzer.jvm :as ana.jvm]) (ana.jvm/analyze 1)"
{:val 1, :type :number, :op :const, :env {:context :ctx/expr, :locals {}, :ns user, :file "<expr>"}, :o-tag long, :literal? true, :top-level true, :form 1, :tag long}

💪 1
borkdude14:12:10

Good work. Tiny typo;

you mask wonder

1
borkdude14:12:25

Would you mean adding an entry on dirname + babashka.fs?

borkdude14:12:14

You may want to share here how to add environment variables for the invocation: https://github.com/pesterhazy/presumably/blob/master/posts/howto-babashka.md#run-a-shell-command FOO=1 dude (shell {:extra-env {"FOO" "1"}} "dude")

pesterhazy14:12:27

Would love to - could you remind me of the context of dirname?

pesterhazy14:12:05

My regular Bash preamble for a file called scripts/foo is

set -euo pipefail && cd "$(dirname "${BASH_SOURCE[0]}")/.."

pesterhazy14:12:36

So would be cool to see how to translate this. Will take a look tomorrow

borkdude14:12:50

I don't bother with that and assume that the script executes from the directory I'm in

pesterhazy14:12:50

Is there a way to get your own script name? Like $BASH_SOURCE?

borkdude14:12:06

yes, *file* :)

pesterhazy14:12:15

of course 💡

borkdude14:12:27

note that this must be on the top level, while the file is being evaluated

borkdude14:12:00

(def this-file *file*)
vs
(defn this-file [] *file*)