停止shell通配符扩展? [英] Stop shell wildcard character expansion?

查看:20
本文介绍了停止shell通配符扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译后的命令行程序有什么方法可以告诉 bash 或 csh 它不希望在其参数中扩展任何通配符?

Is there any way for a compiled command-line program to tell bash or csh that it does not want any wildcard characters in its parameters expanded?

例如,人们可能想要一个 shell 命令,如:

For instance, one might want a shell command like:

foo *

简单地返回该字符的数字 ASCII 值.

to simply return the numeric ASCII value of that character.

推荐答案

没有.扩展发生在命令实际运行之前.
您只能在运行命令之前或通过引用星号来禁用 glob.

No. The expansion takes place before the command is actually run.
You can only disable the glob before running the command or by quoting the star.

$ # quote it
$ foo '*'

$ # or escape it
$ foo *

$ # or disable the glob (noglob)
$ set -f
$ foo *

$ # alternative to set -f
$ set -o noglob
$ # undo it by 
$ set +o noglob

这篇关于停止shell通配符扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆