3

In bash I do set -x and set +x enable/disable the debug mode.

I'm aware of how to debug fish script?, but I would like to toggle debug mode in a more precise way, e.g. inside a function.

Question

What is the equivalent of set -x/set -x in Fish shell?

Community
  • 1
  • 1
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
  • You can use the [`breakpoint` builtin command](https://fishshell.com/docs/current/index.html#debugging) from within a function. Is that what you meant? – hek2mgl Oct 06 '16 at 09:28
  • sending TRAP signal and all, I've no idea how to do that, this sound overly complicated for basic debugging – Édouard Lopez Oct 06 '16 at 12:27
  • You read the wrong paragraph, you don't need a trap command. Simply use the `breakpoint` command. That halt's the script and drops you into an interactive debugging session. It's not the same as `-x` but it can be used to debug scripts and you can trigger the breakpoint out of your code without need to run the whole script with `-d` – hek2mgl Oct 06 '16 at 13:14

1 Answers1

7

After this question was posed, fish 3.1 added the fish_trace variable.

So, instead of set -x (which creates an exported variable in fish), set fish_trace 1 triggers a debug display.

Before fish 3.1, there is no equivalent functionality.

faho
  • 14,470
  • 2
  • 37
  • 47