如何解决如何在命令行应用程序用户输入中处理冒号?
var name: String?
print("What is the name?")
if let input = readLine() {
name = input
}
if let name = name {
print("You input: \(name)")
}
我有一个命令行应用程序,要求用户输入可能包含冒号的名称。在macOS zsh终端中,当用户输入冒号时,它将自动完成,看起来像是字典:
acidgate % What is the name? // prompt user for input
acidgate % [Acid Gate: 2020] // the user's input is autocompleted with brackets
这就是我想要的样子:
acidgate % What is the name?
acidgate % Acid Gate: 2020 // no autocomplete
如果我可以在应用程序中禁用此自动完成功能,那将是理想的选择。如果没有,我该如何处理回复?因为如果用户在自动完成括号后手动删除括号,则该字符串具有怪异的伪影:
You input: Acid Gate: 2020� // printing the user's input
但是,如果用户没有删除方括号并输入[Acid Gate: 2020]
,则打印控制台似乎会显示一个干净的字符串:
You input: Acid Gate: 2020
解决方法
似乎正在调用oh-my-zsh
的{{1}}的完成方案。
您应该能够使用不识别冒号的简单版本来覆盖omz补全,例如:
_swift
更多信息:https://superuser.com/questions/686267/disabling-oh-my-zsh-svn-completion
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。