Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: mapfile and proc filesystem, limitation or possible bug
- X-seq: zsh-users 30677
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: linuxtechguy@xxxxxxxxx
- Cc: zsh <zsh-users@xxxxxxx>
- Subject: Re: mapfile and proc filesystem, limitation or possible bug
- Date: Tue, 23 Jun 2026 03:15:26 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=N0ztm4D/NYS83fiYZLPdEKgmPz4qV5tcr9eDKM+SLmQ=; fh=u3fRZMHQrD0jPYg6dsc8wabkr4a8OQ2n3ZBvRt2081o=; b=IQ/gaQaE0FtUuAmZmTVnlMOEfJn57qVJTFuPrEQ+JnPeSAMr3rh3+uOwTxYsELaL8I y7PlBWPmgx53YXV4XUeRJTrMYar2v5M5oSOnvxHCbJCl2jaF95S3RtY/Nc7hymZ0822E qG99k2mBf1CBGKWC77OSBAhzOsHMQNYeVc3/Z3cxPXsyuup8rzN5+4sfQHqxZ5ObaldE +RDH+EbrLOwlMZw2amxU+c8RI2ivPZh6OSKuW3INEbHPbX6EDUKl3nUhNXK0zVLgCNng wQFN0ZFkLYkRLWR3Y3yCBi+WWXGjBsQyD4XxJd2qnvWdzVWtPl8FziHQA6hYQvzYcNfg myfQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1782177341; cv=none; d=google.com; s=arc-20240605; b=c/FuAbHDYj0EgX9wDEwUGL9OcmAeRrFTbXmCZKeOFKhIL4DBYKWINQDpnNRzyVV1aI XX5qA38tehdmpbXuCWTmLs9BO/JEbV8XvRc2xB/nj7FuFtNSXyu2uujjS8TQZcvY7oGz gkI3O7Vd66nviqt+hO74s/Mo6hy+81Fm4IeZWApkFgfkdR6slShHKLEIOJjq1sreQcrT 2PVRAGM7jgawRjI25wiieh0gt5OyGyvPnnpXyJxD0Lix8ovTlYFdYdIVGoZ20JcMIFwD xc0Gx59OtrN6ldckHUHYKzQYNPfflrGFKHXatZXjscfSbNFkaR2mDF5cS+8d1nK1ndaq KpTQ==
- Archived-at: <https://zsh.org/users/30677>
- In-reply-to: <CA+rB6GK3uNBh42y5b_XzocQ=CZBTbmXPDYT50iisytS7Q+mTMw@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CA+rB6GK3uNBh42y5b_XzocQ=CZBTbmXPDYT50iisytS7Q+mTMw@mail.gmail.com>
On Tue, Jun 23, 2026 at 12:52 AM Jim <linux.tech.guy@xxxxxxxxx> wrote:
>
> Hello,
>
> ZSH_VERSION: 5.9.1
>
> Is there a limitation with mapfile when it comes to the proc filesystem or is there a bug?
> In a normal directory like $HOME the following work as expected:
>
> % cd $HOME
> % print ${(ok)mapfile)
> outputs all names
> % [[ -v mapfile[.zshrc] ]] && print Found || print Not Found
> outputs: Found
> % array=("${(f@)${mapfile[.zshrc]%$’\n’}}")
> array is populated
>
> In a proc directory it does not
>
> % cd /proc/$$
> % print ${(ok)mapfile)
> outputs all names as expected
> % [[ -v mapfile[status] ]] && print Found || print Not Found
> outputs: Not Found
> % array=("${(f@)${mapfile[status]%$’\n’}}")
> array contains one empty element
>
> The man page lists a number of mapfile LIMITATIONS, but I didn't see anything that I
> interpreted as the proc filesystem. If it is a limitation should something more clear be
> added to the manpage?
>
> There are other ways of checking files and getting data from the proc files, but I was
> hoping to determine why mapfile doesn't work.
>
> % print ${(t)mapfile} -> association-hide-hideval-special
> % print ${(t)commands} -> association-hide-hideval-special
>
> The above both have the same keywords defining them, and still outputs as expected.
> % [[ -v commands[nvim] ]] && print Found || print Not Found
> outputs Found
>
> The only difference I can tell, from my previous examples with mapfile, is different
> filesystem types.
>
> Any clarification would be appreciated.
Files in /proc tend to have a reported size of 0 bytes, and the
mapfile module uses stat to see how big to make the buffer for mmap,
which in this case obviously turns out to be 0. If you disable the
mmap path, it uses ftell(..., SEEK_END) to size the buffer to read
into, which also ends up as 0; no data for you.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author