[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug: Bash forgets sourcefile and linenumber of read-in functions
From: |
Chet Ramey |
Subject: |
Re: Bug: Bash forgets sourcefile and linenumber of read-in functions |
Date: |
Mon, 4 Mar 2019 09:16:42 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 |
On 3/3/19 9:53 PM, L A Walsh wrote:
> In bash 4.4.12, if I have some 'library' like functions that I
> read in at login time, and then later call them -- under trace
> or under bashdb, no source is shown, as bashdb (and for trace, bash)
> doesn't seem to be able to retrieve the original source file name and
> line number where the function was defined.
>
> I'm attaching/including 2 files that demonstrate this:
> The first I will call 'lib.sh' that is sourced from my
> /etc/profile and my /etc/bashrc if bashrc can't find the
> function.
>
> ---'lib.sh'---
> #!/bin/bash
> # add numbers passed in and print result to stdout
> addnums() {
> declare -i sum=0
> while (($#)); do
> [[ $1 =~ [-0-9]+ ]] || return -1
> sum+=$1; shift
> done
> printf "%d\n" "$sum"
> return 0
> }
> declare -fxr addnums
>
>
> ---'prog.sh'---
> #!/bin/bash
> # prog: calls addnums on each line read from stdin
> while read ln; do
> addnums $ln
> done
> ---------------
>
> After lib.sh has been sourced, then either trace prog.sh
> or try bashdb and single stepping through 'addnums'.
What does `trace' mean here? If I add these lines to prog.sh:
echo $BASH_VERSION
. ./lib.sh
declare -F addnums
I get
4.4.23(7)-release
addnums 3 ./lib.sh
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- Bug: Bash forgets sourcefile and linenumber of read-in functions, L A Walsh, 2019/03/03
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions,
Chet Ramey <=
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, L A Walsh, 2019/03/04
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, Chet Ramey, 2019/03/04
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, L A Walsh, 2019/03/05
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, Chet Ramey, 2019/03/06
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, L A Walsh, 2019/03/11
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, Greg Wooledge, 2019/03/11
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, L A Walsh, 2019/03/11
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, Greg Wooledge, 2019/03/12
- Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, Chet Ramey, 2019/03/11
Re: Bug: Bash forgets sourcefile and linenumber of read-in functions, Grisha Levit, 2019/03/04