カレントディレクトリの取得
シェルスクリプト
$ pwd
PowerShell
Get-Location
オブジェクトとして得られる。(Path)
code:get_current_dir.ps1
$curDir = $(Get-Location).Path
Convert-Path .
相対パスから絶対パスへの変換コマンドレットに.でカレントディレクトリの相対パスを渡す。
文字列として得られる。
code:get_current_dir.ps1
$curDir = $(Convert-Path .)
Windows コマンドプロンプト
%CD% 環境変数
変数として取り扱うには CD 環境変数を使うのが簡単
chdir コマンド(引数指定なし)
$ chdir
JavaScript(Node.js)
process.cwd()
フルパスが返ってくる。