java – 什么样的应用程序使用getopt“按顺序返回”行为?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 什么样的应用程序使用getopt“按顺序返回”行为?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1512字,纯文字阅读大概需要3分钟。
内容图文
If the first character of optstring is a hyphen (-), then each nonoption argv-element is handled as if it were the argument of an option with character code 1. (This is used by programs that were written to expect options and other argv-elements in any order and that care about the ordering of the two.) The special argument double hyphens (--) forces an end of option-scanning regardless of the scanning mode.
引自manual page of Java GetOpt class:
…The second is to allow options anywhere, but to return all elements in the order they occur on the command line. When a non-option element is ecountered, an integer 1 is returned and the value of the non-option element is stored in optarg is if it were the argument to that option. For example, “-a foo -d”, returns first ‘a’, then 1 (with optarg set to “foo”) then ‘d’ then -1. When this “return in order” functionality is enabled, the only way to stop getopt() from scanning all command line elements is to use the special “–” string by itself as described above. An example is “-a foo -b — bar”, which would return ‘a’, then integer 1 with optarg set to “foo”, then ‘b’, then -1. optind would then point to “bar” as the first non-option argv element. The “–” is discarded.
是的,我理解上面所说的内容,但我仍然无法想象什么样的应用程序会使用这样的行为.
有人可以提供一个命令行语法的示例,该语法可能由实现“按顺序返回”行为的应用程序使用吗?
解决方法:
find是一个混合选项和非选项参数的命令的示例,并关注顺序.
内容总结
以上是互联网集市为您收集整理的java – 什么样的应用程序使用getopt“按顺序返回”行为?全部内容,希望文章能够帮你解决java – 什么样的应用程序使用getopt“按顺序返回”行为?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。