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

Re: Intent to Rewrite: pwgen



On Thu, May 31, 2001 at 09:23:06PM +0000, Lars Wirzenius wrote:
> Theodore Tso <tytso@mit.edu>:
> > Actually, I've thought about this some more, and I think I can provide
> > backwards compatibility at the command-line level, at least for
> > scripts.  The trick will be using isatty(0) ala ls to provide
> > different defaults dependin on whether it's being run interactively by
> > a user or being run as a script.  (Of course, the paranoid script
> > writer can use options to force a particular set of behaviours if
> > he/she doesn't want to depend on isatty() working correctly.)
> 
> This is quite non-intuitive, complicated and strange behavior, please
> don't do it.  If nothing else, it makes it harder to debug things by
> testing them out on the command line. (Not that I can see how isatty(0)
> can be used to test interactive use.)

It's not that strange; /bin/ls does it.  If /bin/ls notices that
stdout (sorry, I should have said isatty(1)) is a tty, then the -C
option is implied; otherwise the -1 option is implied.

So there's ample precedent for doing this, and I've never heard
screams of script writers who use /bin/ls in their shell scripts.  :-)

I want to basically doing the same thing.  When run interactively, I
want pwgen to display 20 lines of 8 character passwords on the
display as the default.  The user can then choose one of the passwords
from the screen, and then quickly clear the screen.  That way even if
someone is looking over their shoulder, it reduces the chances of
someone being able to shoulder-surf the password.

If pwgen is run non-interactively, then the existing behaviour of only
outputting one password will happen.  This makes life easier for shell
script authors who want to do things like

	newpass=`pwgen`

This is much like what happens when you run "/bin/ls" and "/bin/ls |
cat", although for different reasons.

						- Ted



Reply to: