stateful / runme

DevOps Notebooks Built with Markdown
https://runme.dev
Apache License 2.0
1.12k stars 36 forks source link

Providing input to a Bash script using the CLI doesn't work very well #623

Open dradtke opened 3 months ago

dradtke commented 3 months ago

I have a simple bash script that I want to execute with the runme CLI:

export NAME=blank
echo "Hello, ${NAME}!"

This outputs Hello, blank! without any prompting to set the NAME variable.

Following the guide on bash scriptiong suggests the read command, which does work better:

echo "Enter your name:"
read NAME
echo "Hello, ${NAME}!"

This will wait for me to provide input, but it doesn't show the input as I type. It's like entering a password, where the characters are hidden, but when I press Enter it becomes clear that they were accepted after all. When run directly, Bash's read command shows your input as you type, and runme should ideally do the same.

Tested with runme version 3.4.0 (004c66dc1eb498d0c829c47b29ee7841458a5338) on 2024-07-01T16:34:47Z on x64 Linux.

sourishkrout commented 3 months ago

Thanks for reporting this issue @dradtke We'll get back to you soon.

sourishkrout commented 2 months ago

Hi @dradtke. Just to confirm, did you use the CLI when this issue occurred? I seem not to be able to reproduce the issue in both CLI and extension, but I might be missing relevant steps. Please see the video below and let me know.

https://github.com/user-attachments/assets/b73bc13f-3654-4469-a247-e93dcffc9a16

sourishkrout commented 2 months ago

Btw, I'd suggest using Runme's builtin environment variable prompting based on exported vars. It avoids cluttering the cells with stdin reader logic and matches how documentation is written.

image

Please note that when you quote export NAME="Sebastian" the var's value will be used as placeholder whereas no-quotes export NAME=Enter your name will result in a prompt message. Learn more here: https://docs.runme.dev/configuration/cell-level#set-environment-variables

export NAME=Enter your name
echo "Hello, ${NAME}!"
cbeagan commented 1 month ago

Hi @sourishkrout , I face the same issue using the CLI image

It works in the extension image