On Sun, Mar 3, 2019 at 9:56 PM L A Walsh <b...@tlinx.org> wrote:
> The first I will call 'lib.sh' that is sourced from my
> /etc/profile
[snip]
> declare -fxr addnums
[snip]
> ---'prog.sh'---
> #!/bin/bash
> # prog: calls addnums on each line read from stdin
> while read ln; do
>   addnums $ln
> done
> ---------------

It looks like you're exporting a function definition, which makes it
available to prog.sh.  Earlier you said that the reported filename was
"environment" which, makes sense then -- if you run prog.sh as a
script, it only knows about the addnums function because it's in the
environment, it doesn't have any way to inherit the source filename
and line number.  If you change prog.sh to source lib.sh rather than
rely on the imported definition, you should get the debugging
information you're looking for.

Reply via email to