bash 左侧多部分命令的别名
我有一个命令(在 Linux Bash 中),我想阻止自己使用特定选项运行。但是,我仍然想使用其他选项运行该命令。因此,例如以下内容是可以的:
command opt1
command opt2
但我想禁用
command badopt
我正在考虑通过将其别名为我的配置文件中不存在的命令来执行此操作,例如
alias "command badopt"=djskagldjkgldasg
但这似乎不起作用。对于(轻松地)禁用我使用此特定选项的能力,同时保留我使用其他选项的能力,还有其他建议吗?
I have a command (in Linux Bash) that I want to prevent myself from ever running with a specific option. However, I want to still run that command with other options. So for example the following are OK:
command opt1
command opt2
But I want to disable
command badopt
I was thinking of doing this by aliasing it to a nonexistant command in my profile, like
alias "command badopt"=djskagldjkgldasg
but this doesn't seem to work. Any other suggestions for (easily) disabling my ability to use this specific option while preserving my ability to use other options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
# 已更新
# updated
bash 函数就是你想要的。假设你要拦截的命令名为“foo”:
关键字
command
用于防止函数递归调用自身。bash functions are what you want. Assuming the command you want to intercept is named "foo":
The keyword
command
is used to prevent the function from calling itself recursively.