Skip to content

Shell commands could be run interactively (to see the output as it is printed and for visual commands) #10

Open
@vindarel

Description

@vindarel

Currently Clesh's shell-command uses sb-ext:run-program where the output goes to a stream

  (with-input (input-stream (or input :none))
    (let* ((process (sb-ext:run-program
                     *bourne-compatible-shell*
                     (list "-c" command)
		     :wait nil :input input-stream
		     :output :stream
		     :error :stream))

and the output is printed at once, when the command is finished. We don't see the output as it goes:

 echo t; sleep 0.1; echo 2; sleep 0.2; echo 3

if we used uiop:run-program we could use :interactive outputs:

(uiop:run-program (string-left-trim "!" text)
                    :output :INTERACTIVE
                    :error-output :INTERACTIVE
                    :input :INTERACTIVE)

this will show the output as it goes.

And it works for visual commands such as top, sudo, vim…

The interactive input won't work on Emacs and Slime. We can still check the current terminal is not "dumb" with $TERM that shouldn't be "dumb".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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