help-bash
[Top][All Lists]
Advanced

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

Re: Bash bug?


From: Leonid Isaev
Subject: Re: Bash bug?
Date: Tue, 24 Jan 2023 15:59:55 +0000
User-agent: Mutt/1.13.4 (2020-02-15)

On Tue, Jan 24, 2023 at 10:28:32AM -0500, Greg Wooledge wrote:
> Normally, I'd suggest you use mapfile when you've got multiple lines
> of input, and each line can be arbitrarily long or complex.  Use IFS/read
> when you've got a single line, and you're trying to "split" it into
> an array of fields (like the over-simplistic way people try to parse a
> CSV file, which is doomed to failure in any real-life case).
>
> By the way, when using IFS/read for parsing "CSV-like" input, beware of
> the "empty fields at the end" pitfall.
> https://mywiki.wooledge.org/BashPitfalls#pf47

Right, and also of fields with field-separator inside... I use
perl/python/sqlite for parsing CSV files.

> If you can show us a (worst case!) sample of your actual input, we can
> suggest parsing approaches that would be suitable to that input.

Thanks. I don't have such example (I'm not the OP) -- I was just wondering
why mapfile was used...

Sincerely,
-- 
Leonid Isaev



reply via email to

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