Fork me on GitHub
#babashka
<
2021-10-04
>
Benjamin10:10:54

if I have deps defined in bb.edn I also have them in deps.edn, should bb --nrepl automatically pull them? Else how do I pull/load them

borkdude10:10:44

@benjamin.schwerdtner deps are not included automatically from deps.edn. Right now you'll have to duplicate them in bb.edn

Benjamin10:10:08

@borkdude works now thanks

dabrazhe14:10:42

How can I escape single quotes in bb script in clj? The --description string fails in the java sh command but work in terminal

aws iam create-role --role-name account-role --description 'Cloud Ops role' ...

scgilardi15:10:33

I think the purpose of the single quotes at the terminal is to ask the shell to pass to the aws command Cloud Ops Role as a single (string) argument. I would try leaving out the single quotes and passing what's between them as the next item in the array of strings after --description, like: (sh ... "--description" "Cloud Ops role" ... )

dabrazhe15:10:47

This does not work because cli expects to quote the strings with spaces like 'Cloud Ops role'

borkdude15:10:54

@dennisa Can you give the full example? I feel like I'm missing some context

borkdude15:10:44

@dennisa I recommend using babashka.process/tokenize if you want to tokenize a shell string into multiple parts. E.g.:

user=> (babashka.process/tokenize "hello there 'i am a string'")
["hello" "there" "i am a string"]

👍 1
borkdude16:10:19

As @U06C3GHJR was saying: you can omit the single quotes around 'i am a string'` since in shells this just denotes that this is a single string

dabrazhe09:10:56

tokenize had resolved it, by own version of tokenize was too basic for this use case. Thanks!

👍 1
borkdude16:10:54

This is list of companies using babashka: https://github.com/babashka/babashka/blob/master/doc/companies.mdhttps://t.co/svvkxvt4Pg?amp=1 Is your company using babashka too, let me know in the issue!

1
dabrazhe17:10:02

This works fine with bash

aws iam update-role --role-name account-role-ops --description "Cloud Ops-IaC role" --p istest
or
aws iam update-role --role-name account-role-ops --description 'Cloud Ops-IaC role' --p istest
But the same command fails with sh

borkdude17:10:35

Just try this:

@(babashka.process/process "ls -la" {:inherit true})

borkdude17:10:42

with your command as a single string

borkdude18:10:08

(with a recent version of babashka)

🆒 1
dabrazhe08:10:58

-ls la works for me, it's not representative, the question is to escape the single quotes. (I am using clojure.java.shell in repl)

dabrazhe09:10:22

I was able to resolve it! ) You babashka.process/tokenize does a better job of splitting the command string than mine: )

(defn splitcomm [& comm]
  (remove str/blank? (clojure.string/split (apply print-str comm) #"\s")))
its split it in the wrong way somewhere , i guess ...