Fork me on GitHub
#babashka
<
2023-04-13
>
furiel11:04:22

I have a question about the tokenizer in babashka/process. I am rewriting an existing bash script, which calls a testing tool through another process. The testing tool accepts a logical expression of conditions az an argument, but the expression needs to be passed as a single parameter. Something like: bash -c "./tester.sh --formula 'cond1 and cond2'" Now if I call the tokenizer or shell command, the result looks like:

bash -c "./tester.sh --formula 'cond1 and cond2'"
["bash" "-c" "./tester.sh --formula cond1 and cond2"]
which almost what I expect: the argument after bash -c kept together, but the single quotes are omitted for some reason. This is a problem, as the ./tester.sh will receive cond1 , and, and cond2 as separate parameters. It sounds like a bug for me but Iā€™m not sure. If I swap the quotes, then it starts working:
bash -c './tester.sh --formula "cond1 and cond2"'
["bash" "-c" "./tester.sh --formula \"cond1 and cond2\""]

āœ… 2
borkdude11:04:38

Please specify your babashka version

borkdude11:04:57

I'm asking because I think something around this got fixed recently

borkdude11:04:27

or are you using process from the JVM?

furiel11:04:33

babashka v1.1.172

borkdude11:04:43

can you upgrade and try again?

furiel11:04:49

sure, checking

furiel12:04:38

Yes, that was the problem. After upgrading, it works now as expected. Thank you for your help.

šŸ‘ 2
tcarls12:04:43

BTW, I'd like to question whether the bash -c is really important here. You're starting a copy of bash, and then telling it to run ["./tester.sh" "--formula" "cond1 and cond2"] , but as soon as it does the execve() to invoke that copy of tester.sh, the copy of bash is out of the picture and having no impact on runtime behavior (other than maybe signal handling during shutdown, which it may or may not be in the path for depending on whether your particular version of bash recognizes that as a place where it can put in place implicit exec behavior and get out of the way); why not skip the middle and execute that directly?

furiel12:04:09

It does not. I used bash to have a minimal simple example. The real application uses ssh -J jumphost remote-ip "..."

richiardiandrea16:04:22

Dear channel, I am trying to have bbparse arguments for a task and therefore I added:

{:requires ([carat.vessel-mapping :as vessel-mapping])
                          :task (exec vessel-mapping/make-cardiodi-mapping)}
However when I run it, I get
25:   nil
26: (exec vessel-mapping/make-cardiodi-mapping))) generate-carat-mapping
    ^--- Invalid number: 23b8cfb8
What am I doing wrong?

richiardiandrea16:04:37

Never mind, I found the problem, I did not quote the function to call

āœ… 2