ITADN

I'm eager to implement this. A few questions we need first:

#1214Openrubimoutlook740-bot 创建于 2026-01-11
I'm eager to implement this. A few questions we need first: **Interface** Should the interface be a block-scope argument (`begin --trace; ... ; end`), a variable (`set fish_trace 1`), or a new command (`fish_trace --on`)? I'm leaning towards a variable. The reason is that a variable gets a lot of flexibility for free via the scoping: 1. You can debug startup scripts through an environment variable: env fish_trace=1 fish ... 2. You can debug hangs in completions, prompts, etc by setting this as a global variable: set -g fish_trace 1 3. You can trace the "top level" of a script or drill down into functions, by setting it as a local vs global variable. The downside is that it's somewhat harder to use options with a variable. For example if we wanted to control the tracing output we would need to somehow encode that in the value of the variable (`fish_trace=ALL` or whatever). **When to print** bash prints commands after expansion but before execution. Example: zzz=99999 sleep $zzz will print: + sleep 99999 The advantage of printing *before* running is that long-running commands get printed. The disadvantage is that you can't see the exit status, which would be really useful in debugging. I'd like to find a way to trace both the exit status and the command itself. **What to print** bash and zsh expand the $PS4 variable like a prompt and prints that. [zsh has substitutions](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) like `%N` which are flexible but opaque (this is zsh after all). My sense is that rather than providing a DSL here, we should just have different trace levels: set fish_trace 1 # prints basic information, e.g. no file or line numbers set fish_trace 2 # prints more detailed information including file and line numbers and so on. _Originalmente postado por @ridiculousfish em https://github.com/fish-shell/fish-shell/issues/3427#issuecomment-520176772_
0 条评论