Zsh のデバッグって皆どうやっているのだろう?というのがわからなかったが、
zplug のリポジトリ 経由で awesome-zsh-plugins をみていたら
zshdb というツールがあったので試してみることにした。
このツールの方が使いやすいよ!とかあればコメント歓迎です。
zshdb とは?
zshdb とは zsh スクリプトのためのデバッガー。
https://github.com/rocky/zshdb
インストール
$ git-clone git://github.com/rocky/zshdb.git
$ cd zshdb
$ ./autogen.sh # Add configure options. See ./configure --help
$ make && make test
$ ./zshdb /etc/zsh/zshrc
$ make install
$ zshdb -V
zshdb, release 0.92
動作確認
対象コード
VAR1="hoge"
VAR2="hige"
VAR3="hage"
VAR1="hoge updated"
eval: echo $VAR1$VAR2$VAR3
実行
$ zshdb sample.zsh
zsh debugger, zshdb, release 0.92
Copyright 2008-2011, 2014, 2016 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
(/path/to/sample.zsh:1):
VAR1="hoge"
zshdb<0> next
(/path/to/sample.zsh:2):
VAR2="hige"
zshdb<1> help
Available commands:
action break continue display enable export info next print return shell source step- unalias up
alias complete delete down eval frame kill next+ pwd run show step tbreak undisplay
backtrace condition disable edit examine help list next- quit set skip step+ trace untrace
Readline command line editing (emacs/vi mode) is available.
Type "help" followed by command name for full documentation.
zshdb<1> break 5
Breakpoint 1 set in file /path/to/sample.zsh, line 5.
zshdb<1> continue
Breakpoint 1 hit.
(/path/to/sample.zsh:5):
eval: echo $VAR1$VAR2$VAR3
zshdb<4> list
1: VAR1="hoge"
2: VAR2="hige"
3: VAR3="hage"
4: VAR1="hoge updated"
5: => eval: echo $VAR1$VAR2$VAR3
zshdb<4> print VAR1
VAR1
zshdb<4> print $VAR1
hoge updated