zoukankan      html  css  js  c++  java
  • linux程序命令行选项的3种风格:unix、gnu、x toolkit

    In Unix-like systems, the ASCII hyphen-minus is commonly used to specify options. The character is usually followed by one or more letters. Two hyphen-minus characters (--) often indicate that the remaining arguments should not be treated as options, which is useful for example if a file name itself begins with a hyphen, or if further arguments are meant for an inner command. Double hyphen-minuses are also sometimes used to prefix "long options" where more descriptive option names are used. This is a common feature of GNU software. The getopt function and program, and the getopts command are usually used for parsing command-line options.

     

    Unix 风格:单个减号 -

    在选项需要加参数的时候,紧跟在选项后面即可(或者加空格)。比如登录 mysql server 的时候:

    $ mysql -u root -p
    

    或者

    $ mysql -uroot -p
    

    均可。这时,root 就是 u 的参数,表示使用 root 用户登录。另外加不加空格看程序怎么才处理了,没有明确的规定。

    GNU 风格:双减号 --

    使用两个连字符加上关键词(而不是单个字符)。这种风格的出现是因为有一些复杂的 GNU 程序,仅仅 26 个字母(或者算上大小写 52 个)不够使用而发展出来的。另外一个有点是容易理解,因为出现的不再是缩写的字母。选项参数可以使用空格分割也可以使用"="来分割。如:

    $ ls --human-readable --sort=time
    

    如果使用 Unix 风格,那么上条命令则是

    $ ls -ht
    

    是不是更加易读呢?

    X toolkit 风格

    这是一种比较不常见的风格,使用单个连字符加上关键词。只有 X 相关的程序才使用这种风格,一般不建议使用。

    $ xeyes -display joesws:0 -geometry 1000x1000+0+0
    

    看上去和 GNU 风格差不多,只是双连字符改成了单个连字符。

    https://en.wikipedia.org/wiki/Command-line_interface#Arguments

  • 相关阅读:
    动态SQL和PL/SQL的EXECUTE选项分析
    PL/SQL开发中动态SQL的使用方法
    windows 快捷调用
    Windows PE 工具
    面向对象(OOP)五大基本原则
    图像几何变换(geometric transformation)
    BP神经网络模型及梯度下降法
    人工神经元模型及常见激活函数
    Python: PS 滤镜--高反差保留 (High pass)
    Python: PS 滤镜--碎片特效
  • 原文地址:https://www.cnblogs.com/shengulong/p/8434450.html
Copyright © 2011-2022 走看看