Skip to content

Add silent mode in read builtin #838

Closed

Description

@siteshwar

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.

Activity

  1. dag commented on May 27, 2013

    @dag
    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.

  2. terlar commented on May 27, 2013

    @terlar
    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.

  3. jhillyerd commented on Jun 5, 2014

    @jhillyerd

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

  4. jhillyerd commented on Jun 5, 2014

    @jhillyerd

    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
    
  5. leeola commented on Nov 13, 2014

    @leeola

    @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
  6. ByScripts commented on Nov 17, 2014

    @ByScripts
    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.

  7. leeola commented on Nov 25, 2014

    @leeola

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

  8. ridiculousfish commented on Nov 26, 2014

    @ridiculousfish
    Member

    Seems reasonable to me.

  9. zanchey commented on Nov 26, 2014

    @zanchey
    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.

  10. tfga commented on Jul 3, 2015

    @tfga

    @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
  11. Asuza commented on Oct 29, 2015

    @Asuza

    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.

  12. ridiculousfish commented on Nov 5, 2015

    @ridiculousfish
    Member

    This seems like a nice to have feature

  13. cben commented on Feb 12, 2016

    @cben
    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.

  14. krader1961 commented on Apr 12, 2017

    @krader1961
    Contributor

    Closed with squashed merge commit 8213885.

  15. Pysis868 commented on Jun 16, 2017

    @Pysis868

    woo!!

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

  16. faho commented on Feb 1, 2019

    @faho
    Member
  17. mwmcode commented on Feb 1, 2019

    @mwmcode

    Oh! thanks @faho, I was running an older version (2.6) ...just installed the latest (3) via homebrew.

  18. dideler commented on Oct 17, 2019

    @dideler
    Contributor

    FWIW, made a very simple package to hide the input (instead of obscuring it): fish-read-silent

    And an example use case as a dependency in another package: fish-index

  19. locked as resolved and limited conversation to collaborators on Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions