I have installed zsh version 5.6.2 via brew. I am having trouble loading mapfile module.
adding zmodload zsh/mapfile mapfile
gives error ~/.zshrc:15: failed to load module 'mapfile': dlopen(/usr/local/Cellar/zsh/5.6.2_1/lib/mapfile.bundle, 9): image not found
Anyone know how to debug this or a fix ?
To load the zsh/mapfile
module, just run
zmodload zsh/mapfile
You can check that it's correctly loaded with:
zmodload
You should then see the following list of loaded modules:
zsh/complete
zsh/main
zsh/mapfile
zsh/parameter
zsh/zle
zsh/zutil
You can then use it, for example, such as:
# Define a file named pp with three lines
echo yay1 >> pp
echo yay2 >> pp
echo yay3 >> pp
# Build the associative array
arr=("${(f@)mapfile[pp]}")
# Show the content
echo $arr[1]
echo $arr[2]
echo $arr[3]
For explanation about the mapfile module see ZSH Gem #22: Accessing and editing files with mapfile.
For details about the Parameter Expansion Flags see the corresponding section in the Zsh documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With