Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input support in general #13

Open
jcguu95 opened this issue May 15, 2021 · 4 comments
Open

Input support in general #13

jcguu95 opened this issue May 15, 2021 · 4 comments

Comments

@jcguu95
Copy link

jcguu95 commented May 15, 2021

Does cmd support interactive input?

1

For example, (cmd "/tmp/test.bash") does not prompt the user to enter a value, where tmp/test.bash is

#!/bin/bash

read x; echo "$x"; exit;

We can give it a string as input, but that isn't interactive enough if the end goal is to replace shells.

2

Another example arises when the system tries to read a password. For example,

CL> (cmd:cmd "sudo echo a")
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required

Using -S doesn't work either as the repl does not try to read a password.

@ruricolist
Copy link
Owner

There's no special support at the moment, but you can provide cmd with a stream as input:

(with-input-from-string (in "hello")
    (cmd:cmd "~/tmp/test.bash" :< in))

If you want a prompt you can use read-line:

(with-input-from-string (in (read-line))
    (cmd:cmd "~/tmp/test.bash" :< in))

It might be worth adding a :<<< parameter to simplify this.

@ruricolist
Copy link
Owner

Here strings are supported as of 38cb13d.

@jcguu95
Copy link
Author

jcguu95 commented May 16, 2021

Thanks for the patch! It's closer to the general (namely, fully interactive) case :)

Related: joaotavora/sly#448

@vindarel
Copy link

vindarel commented Apr 17, 2023

Hi, I was looking for sudo, and it's working with uiop:run-program:

(uiop:run-program '("sudo" "htop") :output :interactive :input :interactive)

(note the use of the visual htop command, works fine too). Could not find a cmd equivalent. (edit) => use :input :interactive :output :interactive.

(edit)

For example, (cmd "/tmp/test.bash") does not prompt the user to enter a value, where tmp/test.bash is […]

it works too with (cmd:cmd "./test.bash" :input :interactive :output :interactive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants