Mapfile

mapfile

Step-in replacement for bash's 'mapfile' (readarray) builtin. Reads lines from stdin into an indexed array. Strips trailing newlines by default (equivalent to always running with -t). Exports MAPFILE as the default array name; renames to the named array if one is given. Note: -n, -s, and -u options from the real mapfile are not supported.

Arguments

  • $1 (string): Optional: '-t' (accepted but ignored for compatibility)
  • $2 (string): Optional: target array name (default: MAPFILE)

Exit codes

  • 0: Always