Skip to content

Piping input from the shell behaves poorly #218

@kotfu

Description

@kotfu
(Cmd)
Documented commands (type help <topic>):
========================================
_relative_load  help     mumble  pyscript  save  shell      speak
cmdenvironment  history  orate   quit      say   shortcuts
edit            load     py      run       set   show

stty: stdin isn't a terminal
(Cmd) stty: stdin isn't a terminal

Notice how the command is not output by Cmd2, but the prompt is. This means that the output can not be used as a transcript. There are several options to improve the behavior:

  1. Output the prompt and the command. This makes the output a testable transcript.
  2. Output neither the prompt or the command. This makes the output easily parseable by other command line utilities that may want to consume only the output. This is the current behavior of the load command, which does a similar thing.
  3. Make some setting which allows you to choose between option 1 or option 2. Subclasses of Cmd2 could get this setting from a command line switch, or permanently set it one way or the other.

The other problem are the mysterious 'stty: stdin isn't a terminal' messages. A cursory glance at the code in _cmdloop seems to indicate that Cmd2 always expects to read input from a tty. When we run the load command, the commands to run get added to .cmdqueue and nothing is read from stdin.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions