「man」「help」はどこで定義されている?
「man」「help」はCmdletの使い方を1ページずつ出力してくれますが、
この2つのコマンドはどこで定義されているのでしょうか?
「man」「help」の実行例
「get-process」の使い方を調べる
MSH C:\> man get-process NAME get-process SYNOPSIS Gets a list of processes on a machine. ...(中略)... <SPACE> next page; <CR> next line; Q quit
「get-childitem」の使い方を調べる
MSH C:\> help get-childitem NAME get-childitem SYNOPSIS Retrieves the child items of the specified location(s) in a drive. ...(中略)... <SPACE> next page; <CR> next line; Q quit
- [Space]キー
- 次の1ページを表示
- [Enter]キー
- 次の行を表示
- [Q]キー
- 終了
「Cmdlet」でも「alias」でもない
get-command
で表示される「Cmdlet」一覧に「man」「help」は見つかりません。
つまり、「man」「help」≠「Cmdlet」です。
get-alias
で表示される「alias」一覧にも「man」「help」は見つかりません。
「man」「help」≠「alias」です。
「profile.msh」にて発見
「profile.msh」で「man」「help」の記述を見つけました。
※「profile.msh」:profile.mshをカスタマイズする - PowerShell Memoを参照
「profile.msh」を開くと以下の記述があります。
function help { get-help $args[0] | out-host -paging } function man { get-help $args[0] | out-host -paging }
「man」も「help」も「profile.msh」で定義されるグローバル関数ということですね。
「mkdir」と「md」も同様です。
内容としては、1つ目の引数(Cmdlet名)を「get-help」で調査し、その結果を「out-host」に渡しています。