bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug: Bash forgets sourcefile and linenumber of read-in functions


From: Grisha Levit
Subject: Re: Bug: Bash forgets sourcefile and linenumber of read-in functions
Date: Mon, 4 Mar 2019 17:00:22 -0500

On Sun, Mar 3, 2019 at 9:56 PM L A Walsh <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]