osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The "loop and a half"


On 06/10/2017 02:07, Steve D'Aprano wrote:
> On Fri, 6 Oct 2017 09:57 am, Marko Rauhamaa wrote:

> Waiting for input isn't "hangs". That's an ignorant and foolish thing to say,
> more suited for a wet-behind-the-ears newbie than somebody who claims to be a
> long-time old-school programmer.

That's what it looks like. Is it doing something, or waiting for me to 
do something, or did it just hang?

> The Unix commandline interface is not designed to be user-friendly for newbies
> (or experts, for that matter). It is terse, often *painfully* so (would it
> have killed the author to have spelled `umount` correctly?), the UI is
> inconsistent, and it has a very steep learning curve -- a lot of effort is
> required to make a little bit of progress.

OK. I'm not out to change Unix (not right now). But this style of 
utility was suggested as a way to write interactive input loops in 
Python programs, which you might expect to be friendlier.

That it is, to assume from the outset that you're reading from a file, 
not a keyboard. And the user typing in data also has to pretend they are 
entering data in a file, complete with an EOF marker.

That is what I object to.

It is anyway not really acceptable these days for a long list of data to 
simply be typed in like that without any feedback at all. And 100% 
dependent on your typing Ctrl-D at the end and not Ctrl-C by mistake. 
This is not still the 1970s.

> But in fairness, if the author of the `sort` command had a commitment to
> friendliness in their programs, they could have `sort` only print a message
> when it is reading from stdin and writing to stdout, much as `ls` defaults to
> outputting control characters but automatically swaps to replacing them
> with ? when writing to a terminal.

Surely this is a common problem that has long since been solved? You 
have a interactive program - even with proper prompts and feedback - and 
one day you want to run it as a script.

(And properly, by being given the same of an actual file rather than 
using crude redirection.)

But you don't want hundreds of dialogue lines scrolling up the screen 
while it's doing so.

-- 
bartc