OILS / test / gold / lineno.sh View on Github | oilshell.org

23 lines, 10 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./lineno.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10# https://unix.stackexchange.com/questions/355965/how-to-check-which-line-of-a-bash-script-is-being-executed
11
12# This is different than LINENO, see gold/xtrace1.sh.
13
14f(){ echo "${BASH_LINENO[-2]}"; }
15
16echo next1
17f
18
19echo next2
20f
21
22echo next 3
23f