Unix / Linuxでは、オプションの区切り文字としてデュアルダッシュ(--)がいつ、どのように導入されましたか?

Unix / Linuxでは、オプションの区切り文字としてデュアルダッシュ(--)がいつ、どのように導入されましたか?

シェル/ユーティリティではないと思います。歴史的Unixも「最近の」製品ではありません。4.4BSDデュアルダッシュ(または2つの連続ハイフン)の使用をサポートします。オプション区切り記号の終わり。そしてFreeBSDたとえば、次のように表示されます。rm マンページそして2.2.1 リリース(1997).しかし、これは単にコマンドのドキュメントです。

最も古いものを見てGNUファイルツール 変更ログ私が見つけることができるものは次のとおりです(少し修正されました)。

Tue Aug 28 18:05:24 1990  David J. MacKenzie  (djm at albert.ai.mit.edu)

* touch.c (main): Don't interpret first non-option arg as a   <---
  time if `--' is given (POSIX-required kludge).  
* touch.c: Add long-named options.
* Many files: Include <getopt.h> instead of "getopt.h" since
  getopt.h will be in the GNU /usr/include.
* install.c: Declare some functions.
* touch.c, getdate.y, posixtime.y, mktime.c: New files, from bin-src.
* posixtime.y: Move year from before time to after it (but
  before the seconds), for 1003.2 draft 10.

これは以前よりLinux。名前に時間などの桁数を含むファイルを作成したいと思うかもしれないという事実を考えたようです。仕様(10進数8桁または10桁) - 既存のファイルにタイムスタンプを指定する代わりに...


  • これもこうだPOSIX.1二重ダッシュ(--)を次のように紹介します。オプション終了区切り記号Unixシェルでは?
  • 90年代初頭、一部の人々がファイル名に数字を使用したいと思ったので、touchこれはすべて始まりました。
  • 変更ログに表示されるコメントは何ですか?
  • いつガイド10パラメータ - オプションの終わりを示す区切り文字として受け入れる必要があります。 [...]) POSIXについて実用文法

1. 相対的なこれつまり、記録長いオプショングローバルに使用されるすべてのコマンドのうち、これは関係ありません。一方、区切り文字への参照を見ることができます。現れる同様の問題で牛に似た一種の栄養 rm.cコメントとして2000、以前露出2005年のエンドユーザーへ(診断先行ハイフン機能)。しかし、それはすべてずっと後で、非常に具体的なユースケースについてでした。

ベストアンサー1

--私が知っている限り、オプションの終了マークとしての使用はSystem III Unix(1980)で始まりましたshgetopt

これによるとボンシェル家族の歴史、ボーンシェル最初現れるバージョン7 Unix(1979).でもそれは仕方setないパラメータとオプションを分離する。したがって、元のBourneシェルは次のことができます。

  • set -e- エラー終了モードをオンにします。
  • set arg1 arg2 ...- 位置パラメータなどを設定します$1=arg1$2=arg2

しかし:set arg1 -e arg2あなたに与えるでしょう$1=arg1、、$2=arg2そしてオープンエラー終了。こんな。

システムIII Unix(1980)はエラーを修正し、次のようにgetopt。を導入しました。getoptマニュアルページ:

NAME
   getopt - parse command options

SYNOPSIS
   set -- `getopt optstring $∗`

DESCRIPTION
   Getopt is used to break up options in command lines for easy parsing by
   shell procedures, and to check  for  legal  options.   Optstring  is  a
   string  of  recognized  option letters (see getopt(3C)); if a letter is
   followed by a colon, the option is expected to have an  argument  which
   may or may not be separated from it by white space.  The special option
   -- is used to delimit the end of the options.  Getopt will place --  in
   the  arguments  at  the  end  of  the  options, or recognize it if used
   explicitly.  The shell arguments ($1 $2 . . .) are reset so  that  each
   option  is  preceded  by a - and in its own shell argument; each option
   argument is also in its own shell argument.

私が知る限り、これは最初現れる場所。

それ以来、1980年代の非標準時代には、他のコマンドはパラメータの解析のあいまいさを解決するためにこの規則を採用しているようです(例:--上記の例touchと例)。rm

これらの断片的な採用のいくつかは性文化されています。POSIX.1(1988)、「POSIX-required kludge」の変更ログの説明が出てきた。

しかしそれまでPOSIX.2(1992)は次のように信じた。ユーティリティ構文ガイド有名な格言10を含む採用されました。

Guideline 10:    The argument "--" should be accepted as a delimiter
                 indicating the end of options.  Any following
                 arguments should be treated as operands, even if they
                 begin with the '-' character.  The "--" argument
                 should not be used as an option or as an operand.

これが「一緒に砂利を編んだもの」から普遍的に推奨されるものに変わるところです。

おすすめ記事