Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
commands:builtin:mapfile [2012/07/02 04:17]
ormaaj [Bugs] mapfile -n
commands:builtin:mapfile [2019/12/05 16:59] (current)
willdye Fixed a minor syntax error (excess right-paren)
Line 1: Line 1:
 ====== The mapfile builtin command ====== ====== The mapfile builtin command ======
-:V4: 
  
 ===== Synopsis ===== ===== Synopsis =====
Line 44: Line 43:
 A very simple example might be to use it as a kind of progress bar. This will print a dot for each line read. Note the escaped comment to hide the appended words from printf. A very simple example might be to use it as a kind of progress bar. This will print a dot for each line read. Note the escaped comment to hide the appended words from printf.
  
-<​code>​$ printf '​%s\n'​ {1..5} | mapfile -c 1 -C '​printf . \#' ​)+<​code>​$ printf '​%s\n'​ {1..5} | mapfile -c 1 -C '​printf . \#'
 .....</​code>​ .....</​code>​
  
Line 132: Line 131:
  
   * Early implementations were buggy. For example, ''​mapfile''​ filling the readline history buffer with calls to the ''​CALLBACK''​. This was fixed in 4.1 beta.   * Early implementations were buggy. For example, ''​mapfile''​ filling the readline history buffer with calls to the ''​CALLBACK''​. This was fixed in 4.1 beta.
-  * ''​mapfile -n''​ reads an extra line beyond the last line assigned to the array, through Bash ''​4.2.29''​. [[http://​lists.gnu.org/​archive/​html/​bug-bash/​2012-06/msg00072.html|Bug and patch]].+  * ''​mapfile -n''​ reads an extra line beyond the last line assigned to the array, through Bash. [[ftp://​ftp.gnu.org/​gnu/​bash/​bash-4.2-patches/​bash42-035 | Fixed in 4.2.35]]. 
 +  * ''​mapfile'' ​callbacks could cause a crash if the variable being assigned is manipulated in certain ways. [[https://​lists.gnu.org/​archive/​html/​bug-bash/​2013-01/msg00039.html]]. Fixed in 4.3.
 ===== To Do ===== ===== To Do =====
   * Create an implementation as a shell function that's portable between Ksh, Zsh, and Bash (and possibly other bourne-like shells with array support).   * Create an implementation as a shell function that's portable between Ksh, Zsh, and Bash (and possibly other bourne-like shells with array support).