fish-shell / fish-shell/fish-shell
FR extend status stack-trace with --format "%F %f:%l"
- Dominant language
- Rust
- Stars
- 34.2k
- Forks
- 2.4k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 13
Description
some people prefer gnu/C style format instead of wordy one
```
in foo() file:12
in bar() file:23
```
or functions only, or in one line
```
foo() <- main()
```
my impl / wrapper, where main caveat is cumbersome sed/rg regexp
```fish
function stacktrace
argparse 'f/format' 'd#drop' -- $argv
set -q _flag_format
and set format $_flag_format
or set format " %F %f:%l"
status stack-trace |
sed -zE 's,\n\s+called , ,g ' |
rg -o 'function .?(\w+).?\b.*\bline (\d+)\b.*\bfile (\S+)' -r'$1 $2 $3' |
while read func line file
set -q _flag_drop ;and begin
set _flag_drop (math $_flag_drop - 1)
test "$_flag_drop" -ge 0 ;and continue
end
## ^^ --drop>0 && continue
echo $format | string replace -a '%F' $func |
string replace -a '%f' $file |
string replace -a '%l' $line |
end
end
```
also i saw some fish builtins tells `function called with args [foo "bar baz"]`, does they have some super puper stack-trace ability?
Contributor guide
Assessment
This issue has not been assessed yet.