New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add silent mode in read builtin #838

Closed
siteshwar opened this Issue May 27, 2013 · 16 comments

Comments

Projects
None yet
@siteshwar
Member

siteshwar commented May 27, 2013

In silent mode, typed characters are not shown in terminal, Bash supports silent mode with '-s' flag, so read -s will not echo characters on terminal. We should have similar flag in fish's read builtin.

@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag May 27, 2013

Contributor

On the one hand I want to say that fish scripting is mainly meant for scripting fish, I think, and what use does this have for that? On the other hand, I'm a sucker for security and think shoulder surfing is scary!

Maybe we could have it print asterisks or bullets for each typed character, mimicking GUI password inputs? Some feedback that the keys actuated and that the input got sent to the right window/terminal.

Contributor

dag commented May 27, 2013

On the one hand I want to say that fish scripting is mainly meant for scripting fish, I think, and what use does this have for that? On the other hand, I'm a sucker for security and think shoulder surfing is scary!

Maybe we could have it print asterisks or bullets for each typed character, mimicking GUI password inputs? Some feedback that the keys actuated and that the input got sent to the right window/terminal.

@terlar

This comment has been minimized.

Show comment
Hide comment
@terlar

terlar May 27, 2013

Contributor

Another thing that this got me thinking about would be auto-accepting, like it takes one char and then accepts it.

Do you want to continue [Y/n], y, and that would send the command directly. Sorry for bringing that up in this issue though.

Contributor

terlar commented May 27, 2013

Another thing that this got me thinking about would be auto-accepting, like it takes one char and then accepts it.

Do you want to continue [Y/n], y, and that would send the command directly. Sorry for bringing that up in this issue though.

@jhillyerd

This comment has been minimized.

Show comment
Hide comment
@jhillyerd

jhillyerd Jun 5, 2014

@dag I'd like to be able to prompt for a password as part of setting up my proxy server environment variables.

jhillyerd commented Jun 5, 2014

@dag I'd like to be able to prompt for a password as part of setting up my proxy server environment variables.

@jhillyerd

This comment has been minimized.

Show comment
Hide comment
@jhillyerd

jhillyerd Jun 5, 2014

This is my workaround, not sure how portable it is:

echo -n 'Proxy Password: '
stty -echo
head -n 1 - | read -l pass
stty echo
echo

jhillyerd commented Jun 5, 2014

This is my workaround, not sure how portable it is:

echo -n 'Proxy Password: '
stty -echo
head -n 1 - | read -l pass
stty echo
echo
@leeola

This comment has been minimized.

Show comment
Hide comment
@leeola

leeola Nov 13, 2014

@dag

On the one hand I want to say that fish scripting is mainly meant for scripting fish, I think, and what use does this have for that?

I'm not sure what you mean by that. How is a silent read option, not fish scripting?

Regarding what use it has, the i think it would have the same uses as read -s in bash. Sensitive information (passwords), etc.

As a sidenote, a silent option would be great, as the alternative seems to be this verbose option:

stty -echo
if not read foo
  stty echo
  exit $status
stty echo

leeola commented Nov 13, 2014

@dag

On the one hand I want to say that fish scripting is mainly meant for scripting fish, I think, and what use does this have for that?

I'm not sure what you mean by that. How is a silent read option, not fish scripting?

Regarding what use it has, the i think it would have the same uses as read -s in bash. Sensitive information (passwords), etc.

As a sidenote, a silent option would be great, as the alternative seems to be this verbose option:

stty -echo
if not read foo
  stty echo
  exit $status
stty echo
@ByScripts

This comment has been minimized.

Show comment
Hide comment
@ByScripts

ByScripts Nov 17, 2014

Contributor

Any news on that issue? Would be great.

Thanks for the workaround though.

Edit: Just tried the workaround. Didn't work. After stty -echo I can still see the characters.

Contributor

ByScripts commented Nov 17, 2014

Any news on that issue? Would be great.

Thanks for the workaround though.

Edit: Just tried the workaround. Didn't work. After stty -echo I can still see the characters.

@leeola

This comment has been minimized.

Show comment
Hide comment
@leeola

leeola Nov 25, 2014

@ridiculousfish Any comment on this? A proper silent option is really useful (needed even?)

leeola commented Nov 25, 2014

@ridiculousfish Any comment on this? A proper silent option is really useful (needed even?)

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Nov 26, 2014

Member

Seems reasonable to me.

Member

ridiculousfish commented Nov 26, 2014

Seems reasonable to me.

@zanchey

This comment has been minimized.

Show comment
Hide comment
@zanchey

zanchey Nov 26, 2014

Member

read -s is currently used to enable "shell" mode in the trunk source (not released) so either that needs to be moved or another option needs to be specified.

Member

zanchey commented Nov 26, 2014

read -s is currently used to enable "shell" mode in the trunk source (not released) so either that needs to be moved or another option needs to be specified.

@tfga

This comment has been minimized.

Show comment
Hide comment
@tfga

tfga Jul 3, 2015

@jhillyerd's code as a function:

function readPasswd # prompt targetVar

    echo -n $argv[1]
    stty -echo
    head -n 1 | read -g $argv[2]
    stty echo
    echo

end

tfga commented Jul 3, 2015

@jhillyerd's code as a function:

function readPasswd # prompt targetVar

    echo -n $argv[1]
    stty -echo
    head -n 1 | read -g $argv[2]
    stty echo
    echo

end
@Asuza

This comment has been minimized.

Show comment
Hide comment
@Asuza

Asuza Oct 29, 2015

I was writing a script this morning and was rather disappointed to discover I couldn't input via a "password" mode. Hoping this get implemented soon.

Asuza commented Oct 29, 2015

I was writing a script this morning and was rather disappointed to discover I couldn't input via a "password" mode. Hoping this get implemented soon.

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Nov 5, 2015

Member

This seems like a nice to have feature

Member

ridiculousfish commented Nov 5, 2015

This seems like a nice to have feature

@cben

This comment has been minimized.

Show comment
Hide comment
@cben

cben Feb 12, 2016

Contributor

Turns out read uses readline and stores history (#1504).
Does stty -echo interact sanely with readline?
IMNSHO whatever mechanism there will be to read silently should also inhibit history saving [at least by default].
I think this all points to a builtin flag of read being better than "do it yourself" / stdlib function.

Contributor

cben commented Feb 12, 2016

Turns out read uses readline and stores history (#1504).
Does stty -echo interact sanely with readline?
IMNSHO whatever mechanism there will be to read silently should also inhibit history saving [at least by default].
I think this all points to a builtin flag of read being better than "do it yourself" / stdlib function.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 12, 2016

I think this all points to a builtin flag of read being better than "do it yourself" / stdlib function.

👍

For a userland implementation see: #2166 (comment)

ghost commented Feb 12, 2016

I think this all points to a builtin flag of read being better than "do it yourself" / stdlib function.

👍

For a userland implementation see: #2166 (comment)

@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Apr 12, 2017

Contributor

Closed with squashed merge commit 8213885.

Contributor

krader1961 commented Apr 12, 2017

Closed with squashed merge commit 8213885.

@krader1961 krader1961 closed this Apr 12, 2017

@Pysis868

This comment has been minimized.

Show comment
Hide comment
@Pysis868

Pysis868 Jun 16, 2017

woo!!

GitHub - fish-shell/fish-shell - fish 2.6.0 (released June 3, 2017):

  • ...
  • read supports a new --silent option to hide the characters typed (#838), for when reading sensitive data from the terminal. read also now accepts simple strings for the prompt (rather than scripts) with the new -P and --prompt-str options (#802).
  • ...

Pysis868 commented Jun 16, 2017

woo!!

GitHub - fish-shell/fish-shell - fish 2.6.0 (released June 3, 2017):

  • ...
  • read supports a new --silent option to hide the characters typed (#838), for when reading sensitive data from the terminal. read also now accepts simple strings for the prompt (rather than scripts) with the new -P and --prompt-str options (#802).
  • ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment