julia icon indicating copy to clipboard operation
julia copied to clipboard

Allowing disabling the default prompt suffix in `Base.getpass()`

Open JamesWrigley opened this issue 1 year ago • 7 comments

By default Base.getpass() will append : to the prompt, but sometimes that's undesirable, so now there's a with_suffix keyword argument to disable it.

For context, my use-case is showing SSH prompts received from a server verbatim to the user. I did attempt to write a test for this but it would've required a lot of refactoring since getpass() is pretty hardcoded to expect input from stdin :\ An alternative design would be to have a suffix=": " argument instead, but I couldn't think of a good usecase for a user putting the prompt suffix in a separate argument instead of message itself.

JamesWrigley avatar Mar 05 '24 22:03 JamesWrigley

AFAICT the test failures are unrelated.

JamesWrigley avatar Mar 06 '24 09:03 JamesWrigley

In the future, if you just click the "Commit suggestion" button then it is easier to review. Otherwise the reviewer needs to manually check that you incorporated the suggested change.

stevengj avatar Apr 03 '24 20:04 stevengj

In the future, if you just click the "Commit suggestion" button then it is easier to review. Otherwise the reviewer needs to manually check that you incorporated the suggested change.

Ah sure, will do in the future :+1:

JamesWrigley avatar Apr 03 '24 21:04 JamesWrigley

(bump)

JamesWrigley avatar Apr 17 '24 15:04 JamesWrigley

(bump)

JamesWrigley avatar May 07 '24 14:05 JamesWrigley

I don't understand the purpose of a "suffix". Is it so bad to have to write

Base.getpass("Password: ")

instead of

Base.getpass("Password")

?

barucden avatar May 07 '24 14:05 barucden

Well, I can imagine it's a convenient default since a colon is a very common suffix. But removing it would be backwards incompatible so it doesn't really matter if it's useful or not.

JamesWrigley avatar May 07 '24 16:05 JamesWrigley

(bump)

JamesWrigley avatar Jun 06 '24 23:06 JamesWrigley

(bump)

JamesWrigley avatar Jul 19 '24 13:07 JamesWrigley

I took the liberty to add a few tests here. I would be surprised if the Windows CI passes, but I figured it was worth a shot. We can disable them on Windows if it fails.

mbauman avatar Jul 19 '24 19:07 mbauman

Argh, I didn't expect that changing a test file would break the build.

mbauman avatar Jul 19 '24 19:07 mbauman

Thanks for putting in the effort to write tests :)

JamesWrigley avatar Jul 22 '24 14:07 JamesWrigley

Well I was gonna complain that this didn't add tests, but then I realized that getpass didn't have any tests in the first place... and as someone who has touched that implementation I'm partly to blame for that!

I think this is now good to go!

mbauman avatar Jul 22 '24 15:07 mbauman