bash trap EXIT $LINENO always 1

1k Views Asked by At

test.sh

#!/bin/bash
set -e
trap 'echo $LINENO' EXIT
/bin/false

run

$ ./test.sh
1

How may I get the actual line number of "/bin/false" instead of always '1'?

1

There are 1 best solutions below

4
Philippe On BEST ANSWER

You are getting 1 because you trap EXIT. Try :

trap ... ERR