Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Didou Serge Newsgroups: gnu.bash.bug Subject: Re: [mapfile]: problem reentrance with normal file Date: Mon, 12 Nov 2018 16:48:47 +0100 Lines: 64 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1542037747 26242 208.118.235.17 (12 Nov 2018 15:49:07 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org, bash@packages.debian.org To: chet.ramey@case.edu Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GnGJg9odz6We0i33pF8bie1SzNkZFfWr5J6MSJmYlVg=; b=L2QX50K3+UdgpoaukevDo4rf5W6Af3saNFKRIc1Pz5GUpfkbOCBcYpOZQsZ/MfJ3E8 zrChX2XB4M4c+5W2wZCtOG+hviD+mGqk5cPwyphjTzclYzeB/5m5hLILU5iUASvG3s8x NfR3Dh0f8SJbAoLxw/y8JaMKWKUc2iACIeECflUJNGMzCIsK159Y+qtCGPCHzZDpLqqz ZDr4rjdpiMCk9opAOvkFh8HjlSjcEswK0LbUfoIc1FvvUuBaGsRUpCL6YXdTQicrEKiH e9s6mKgpFcNNfFt7BnqCWBCR/qJJlRYprlnGqMkxzcStw38+mU2Wmw9t/8tvgFep9h/h bDaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GnGJg9odz6We0i33pF8bie1SzNkZFfWr5J6MSJmYlVg=; b=FUU8c9/kE5s7+dG1MqTLA40mYDVSXxuF/0LPnFmUymgKlN8FXGF+oVy50v4j74MfUp ADeGgBlIr52a5mJyxN3BQvxnvMoGRrXB2YgitypCRwcIaPGPaAtWWy9c/f3+vCh1PdTD nS1jGbroUQqEQfsD1Rhq5voJh01GNdyDV2EbBK/IY5kEl/NO+j9G9jxlNyAOSvuoRnPt nm/nrlSDrnMrhEioj/UJXwG0BLfD7PPZBa3eMLqVuwke9QLpUL94SJlZjPgmkqIkxZWP eG3+L5DCZmRR74oD0pLsAn92HeQYmZUOd5dCuO/RSfAdmxBY0Dog1ZaeoJNqALyX3wWU lk6w== X-Gm-Message-State: AGRZ1gKSGW1sK4OaW2EDaoXfXSHSeEu2lzCS6GPbcP66rckTIPCJ8Tc8 unMbqXM1zlQbmQKifHkFHR8yHQgbxB6m8Q3FNcs= X-Google-Smtp-Source: AJdET5fLZDvXYKfFoUl7JXenwWqpaWiJdmLQdSius8ufVFLSZ3MyyEpifVgLxbl4VJnxIDhZyr0g0yimNtgYvVZ68iQ= X-Received: by 2002:aa7:de18:: with SMTP id h24-v6mr9228480edv.100.1542037738917; Mon, 12 Nov 2018 07:48:58 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::534 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14797 Ok, in this case, this should not work either: mapfile -C xx -c 1 UU < <( echo -e "Premiere ligne" A{1..45} "\nDeuxieme ligne" B{1..45} "\nTroisieme ligne" C{1..45}) But, this form work fine. Le lun. 12 nov. 2018 =C3=A0 15:44, Chet Ramey a =C3= =A9crit : > On 11/11/18 3:32 PM, Didou Serge wrote: > > > Bash Version: 4.4 > > Patch Level: 7 > > Release Status: release > > > > Description: > > When use mapfile from normal file that call function that use mapfile, > the > > first mapfile lost data. > > > > Repeat-By: > > I create 3 functions: > > ww(){ echo "$@" | mapfile -C yy -c 1 -t TT ; } > > xx(){ mapfile -C yy -c 1 -t TT < <(echo "$@") ; } > > yy(){ echo "$@" ;} > > > > I create 1 normal file: > > echo -e "Premiere ligne" A{1..45} "\nDeuxieme ligne" B{1..45} > "\nTroisieme > > ligne" C{1..45} >fic.txt > > > [...] > > This not work (lost data in second line and after) : > > mapfile -C xx -c 1 UU > 0 0 Premiere ligne A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A= 16 > > A17 A18 A19 A20 A21 A22 A23 A24 A25 A26 A27 A28 A29 A30 A31 A32 A33 A34 > A35 > > A36 A37 A38 A39 A40 A41 A42 A43 A44 A45 > > 0 1 B17 B18 B19 B20 B21 B22 B23 B24 B25 B26 B27 B28 B29 B30 B31 B32 B3= 3 > > B34 B35 B36 B37 B38 B39 B40 B41 B42 B43 B44 B45 > > 0 2 ligne C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C1= 8 > > C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C30 C31 C32 C33 C34 C35 C36 > C37 > > C38 C39 C40 C41 C42 C43 C44 C45 > > This is a buffering issue caused by nested calls to mapfile in the same > process. The first call to mapfile reads a bufferful of data from the > input file, and the second mapfile (the one executed as part of the > callback) reads data into that same buffer. When the second call finishes= , > and the first mapfile is called again, the remaining characters in the > buffer have already been discarded. It's not safe to call mapfile as part > of a callback to a mapfile invocation. > > Chet > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/ >