加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

如何在zsh中读取1个符号?

发布时间:2020-12-14 00:29:28 所属栏目:Linux 来源:网络整理
导读:我需要从控制台获取一个字符而不打印它. 我尝试使用read -en 1,就像我使用bash一样.但这根本不起作用. 并且vared似乎没有这样的选择. 如何在zsh中读取1个符号? (我使用的是zsh v.4.3.11和v.5.0.2) 解决方法 read -sk 从documentation: -s Don’t echo back
我需要从控制台获取一个字符而不打印它.
我尝试使用read -en 1,就像我使用bash一样.但这根本不起作用.
并且vared似乎没有这样的选择.

如何在zsh中读取1个符号? (我使用的是zsh v.4.3.11和v.5.0.2)

解决方法

read -sk

从documentation:

-s

Don’t echo back characters if reading from the terminal. Currently does not work with the -q option.

-k [ num ]

Read only one (or num) characters. All are assigned to the first name,without word splitting. This flag is ignored when -q is present. Input is read from the terminal unless one of -u or -p is present. This option may also be used within zle widgets.

Note that despite the mnemonic ‘key’ this option does read full characters,which may consist of multiple bytes if the option MULTIBYTE is set.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读