Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Evaluating the current source line before it runs

rocky edited this page · 2 revisions

I find I sometimes want to run the line that’s about to be executed to see if I want to step into methods that are called.

For example:


I had been cutting and pasting the command as shown, but realized I could do better if I made a command for this. So that’s what I’ve done.

If you run the eval command without any arguments, it will run the command that is about to be run.

zshdb<2> eval
eval: PROFILES="/etc/apparmor.d"
$? is 0

This was working fine, until I started coming across tests inside if, elsif, and until blocks. For example:

if [ "$1" = "recache" ]
	log_daemon_msg "Recaching AppArmor profiles"

Suppose I want to know which branch I’m going to take before taking the branch. That way I might even be able to change which way to go by changing the test before it runs in the debugged program. (In the above example, I could print $1

zshdb<2> pr $1

But I’m lazy. I’d rather let the debugger do the work for me:

zshdb<1> eval?
eval: [ "$1" = "recache" ]
$? is 1

If you alias eval with a name that ends in ? it will strip off any leading if, case, while, elif, or return.

Something went wrong with that request. Please try again.