1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00

lib/tests/modules.sh: Add loc <depth> optional parameter

This commit is contained in:
Robert Hensing 2024-08-12 13:25:30 +02:00
parent c516c03bf4
commit 6fa24da815

View file

@ -20,10 +20,16 @@ cd "$DIR"/modules
pass=0
fail=0
# prints the location of the call of to the function that calls it
# loc
# prints the location of the call of to the function that calls it
# loc n
# prints the location n levels up the call stack
loc() {
local caller depth
depth=1
if [[ $# -gt 0 ]]; then
depth=$1
fi
# ( lineno fnname file ) of the caller
caller=( $(caller $depth) )
echo "${caller[2]}:${caller[0]}"