Skip to content

Support read bultin for user input #5

@dundalek

Description

@dundalek

When wanting to read user input with:

echo -n "Your name: "
read name
echo Hello "$name"

Gets translated as following which does not work because read is a shell builtin and cannot be executed:

(require (quote [babashka.process :refer [shell pipeline pb]]))
(def name (System/getenv "name"))
(shell "echo" "-n" "Your name: ")
(shell "read" "name")
(shell "echo" "Hello" name)

We could translate it as (read) and introduce a binding which would make it work:

(require (quote [babashka.process :refer [shell pipeline pb]]))
(shell "echo" "-n" "Your name: ")
(def name (read))
(shell "echo" "Hello" name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions