9

You can debug a bash script like this:

bash -x script [arg1 ...]`

Question

What is the fish equivalent?

Community
  • 1
  • 1
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178

2 Answers2

12

Fish use a similar flag system:

fish -d 3 script.fish

Where d is the debug flag followed by the verbosity level:

-d or --debug-level=DEBUG_LEVEL specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.

Community
  • 1
  • 1
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
9

Since https://github.com/fish-shell/fish-shell/issues/3427 was merged there is now

fish_trace=on script.fish

fish_trace is just a variable, so you can set it globally or scope it locally inside functions and scripts

function im-still-debugging
   set -l fish_trace on
   ... etc
end

and turn it off with

set --erase fish_trace

as of fish 3.2, fish ignores the actual value you set, it only cares that it is set.

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61