Eu não acho que haja um comando
funcfiletraceThis array contains the absolute line numbers and corresponding file names for the point where the current function, sourced file, or (if
EVAL_LINENOis set)evalcommand was called. The array is of the same length asfuncsourcetraceandfunctrace, but differs fromfuncsourcetracein that the line and file are the point of call, not the point of definition, and differs fromfunctracein that all values are absolute line numbers in files, rather than relative to the start of a function, if any.funcsourcetraceThis array contains the file names and line numbers of the points where the functions, sourced files, and (if
EVAL_LINENOis set)evalcommands currently being executed were defined. The line number is the line where the ‘function name’ or ‘name ()’ started. In the case of an autoloaded function the line number is reported as zero. The format of each element isfilename:lineno.For functions autoloaded from a file in native zsh format, where only the body of the function occurs in the file, or for files that have been executed by the
sourceor ‘.’ builtins, the trace information is shown asfilename:0, since the entire file is the definition. The source file name is resolved to an absolute path when the function is loaded or the path to it otherwise resolved.Most users will be interested in the information in the
funcfiletracearray instead.funcstackThis array contains the names of the functions, sourced files, and (if
EVAL_LINENOis set)evalcommands. currently being executed. The first element is the name of the function using the parameter.The standard shell array
zsh_eval_contextcan be used to determine the type of shell construct being executed at each depth: note, however, that is in the opposite order, with the most recent item last, and it is more detailed, for example including an entry for toplevel, the main shell code being executed either interactively or from a script, which is not present in$funcstack.functraceThis array contains the names and line numbers of the callers corresponding to the functions currently being executed. The format of each element is
name:lineno. Callers are also shown for sourced files; the caller is the point where thesourceor ‘.’ command was executed.
Comparando:
foo.bash :
#! /bin/bash
yelp() {
caller 0
}
foo () {
yelp
}
foo
foo.zsh :
#! /bin/zsh
yelp() {
print -l -- $funcfiletrace - $funcsourcetrace - $funcstack - $functrace
}
foo () {
yelp
}
foo
Os resultados:
$ bash foo.bash
7 foo foo.bash
$ zsh foo.zsh
foo.zsh:7
foo.zsh:10
-
foo.zsh:2
foo.zsh:6
-
yelp
foo
-
foo:1
foo.zsh:10
Portanto, os valores correspondentes estão em ${funcfiletrace[1]} e ${funcstack[-1]} . Modificando yelp para:
yelp() {
print -- $funcfiletrace[1] $funcstack[-1]
}
A saída é:
foo.zsh:7 foo
que é bem próximo do bash
7 foo foo.bash