奇妙なsetopt動作

奇妙なsetopt動作

一部のオプションでは、setoptは効果がありません。

➜  ~  setopt | grep history
extendedhistory
➜  ~  setopt appendhistory
➜  ~  setopt | grep history # appendhistory apparently didn't get set
extendedhistory
➜  ~  setopt sharehistory
➜  ~  setopt | grep history # but sharehistory does
extendedhistory
sharehistory

なぜ?

ベストアンサー1

setopt現在のシミュレーションモードとの偏差を出力します。シミュレーションappendhistoryのデフォルト設定ですzsh

すべてのオプションのステータスを表示するには、を使用できますset -o

引用文書:

 If no arguments are supplied, the names of all options currently
 set are printed.  The form is chosen so as to minimize the
 differences from the default options for the current emulation (the
 default emulation being native zsh, shown as <Z> in *note
 Description of Options::).  Options that are on by default for the
 emulation are shown with the prefix no only if they are off, while
 other options are shown without the prefix no and only if they are
 on.  In addition to options changed from the default state by the
 user, any options activated automatically by the shell (for
 example, SHIN_STDIN or INTERACTIVE) will be shown in the list.  The
 format is further modified by the option KSH_OPTION_PRINT, however
 the rationale for choosing options with or without the no prefix
 remains the same in this case.

おすすめ記事