help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does mapfile support a multibyte character for its delimiter option?


From: Greg Wooledge
Subject: Re: Does mapfile support a multibyte character for its delimiter option?
Date: Wed, 7 Jul 2021 14:29:07 -0400

On Wed, Jul 07, 2021 at 02:13:29PM -0400, Lawrence Velázquez wrote:
> On Tue, Jul 6, 2021, at 10:49 PM, Robin A. Meade wrote:
> > Consider:
> > 
> > $ mapfile -d ¥ -t a < <(echo -n 1¥2¥3¥)
> > 
> > $ declare -p a
> > declare -a a=([0]=$'1\302' [1]=$'\2452\302' [2]=$'\2453\302' [3]=$'\245')
> > 
> > 
> > I expected:
> > 
> > $ declare -p a
> > declare -a a=([0]="1" [1]="2" [2]="3")
> 
> https://git.savannah.gnu.org/cgit/bash.git/tree/builtins/mapfile.def?id=ce23728#n147

Not very informative on its own.  The delim argument is passed to
a function named zgetline() which is not defined here.

Apparently zgetline comes from lib/sh/zgetline.c.  Here, we have int delim
and char c, and the following line which compares them:

      if (c == delim)

So, any delimiter that doesn't fit within a "char" is going to fail here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]