Re: mapfile weirdness ^@ is added it would seem if output is quoted

2024-01-02 Thread Chet Ramey

On 1/1/24 4:38 PM, Federer Fanatic wrote:

Consider the following:

shopt -s extdebug
mapfile -d" " < <(declare -F 

This isn't actually a reproducer, since, as others have said, declare -F
doesn't read stdin.

Can you provide a function definition and a value for `some rc file' that
others can use to reproduce this? Since you're using a space as the
delimiter, it's expected that MAPFILE[2] will have a trailing newline.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: mapfile weirdness ^@ is added it would seem if output is quoted

2024-01-01 Thread Greg Wooledge
On Mon, Jan 01, 2024 at 04:38:20PM -0500, Federer Fanatic wrote:
> Consider the following:
> 
> shopt -s extdebug
> mapfile -d" " < <(declare -F  Results in the array MAPFILE having 3 entries with '2' entry containing the
> filename
> of bash function initial defining line

I don't think this is correct.  You're showing the command "declare -F < file"
but declare -F doesn't read stdin at all.

unicorn:~$ declare -F
declare -f crawl
declare -f fput
declare -f git
[...]
unicorn:~$ echo 'f() { echo f; }' > x
unicorn:~$ mapfile -d" " < <(declare -F  $ vim "${MAPFILE[2}}" causes failure, not just for vim but cat for
> example, however

*What* failure?

> $ vim ${MAPFILE[2]} does not add '^@' at the end of the fle name,

Without seeing what's actually in your MAPFILE array, it's hard to
understand what you're saying here.  ^@ is how vim displays a NUL byte.
Are you simply trying to edit a binary file?  That would very likely
give you some instances of ^@ on your screen, one for each NUL byte
in the currently-visible part of the file.

Also, your bug report doesn't include which version of bash you're
running.

Please tell us:

 * Which version of bash.
 * What's in the file you're using.
 * The *exact* command you're running, including the filename.
 * The actual output you get.

Please be sure to include "declare -p MAPFILE" to show the contents of
the array.



mapfile weirdness ^@ is added it would seem if output is quoted

2024-01-01 Thread Federer Fanatic
Consider the following:

shopt -s extdebug
mapfile -d" " < <(declare -F  /lib/x86_64-linux-gnu/libtinfo.so.6 (0x7fa3b23c8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x7fa3b21a)
/lib64/ld-linux-x86-64.so.2 (0x7fa3b257d000)


--
 Roger Federer Fanatic Extraordinaire :-)