Discussion:
eval and LINENO
(too old to reply)
Peng Yu
2018-11-15 20:26:08 UTC
Permalink
Hi,

For the 2nd eval in main1.sh, the LINENO is not at the actual line
number of the eval command. This behavior is counter-intuitive. Would
it be better to make it show the line number of the 2nd eval? Thanks.

$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

echo "$LINENO"


$ cat main1.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

eval '#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

echo "$LINENO"


'
eval "$(< ./script.sh)"
echo "$LINENO"

$ ./main1.sh
13
14
12
--
Regards,
Peng
Loading...