[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19240: cut 8.22 adds newline
From: |
John Kendall |
Subject: |
bug#19240: cut 8.22 adds newline |
Date: |
Thu, 4 Dec 2014 21:13:37 +0000 |
Paul Eggert wrote:
> On 12/04/2014 10:41 AM, John Kendall wrote:
>> echo "$FILE ===========================\c"| cut -c1-30
>
> Since you're going to have to rewrite it anyway if you want it to be
> portable, I suggest doing it this way:
>
> printf '%.30s' "$FILE ==========================="
>
> as it's a lot more efficient anyway.
Yes, that's what I've done. The corner case I mentioned is
handled badly by this, however. In the corner case $FILE
is a list of files separated by a newlines. Solaris cut would
list them and then the ============= would be tacked
on to the last line:
filename1
filename2
filename3
filename4
filename5 ========================= matches
When printf is used, it truncates the list of filenames if the sum
of them exceeds 30 chars in length. The format string %.30s
doesn't treat embedded newlines specially:
filename1
filename2
filename3 ========================= matches
filenames start getting lopped off.
I'll rework the code. It worked for 15 years, don't be too
offended by it. :)
- bug#19240: cut 8.22 adds newline, John Kendall, 2014/12/01
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/01
- Message not available
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/01
- bug#19240: cut 8.22 adds newline, Pádraig Brady, 2014/12/01
- bug#19240: cut 8.22 adds newline, Paul Eggert, 2014/12/01
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/01
- bug#19240: cut 8.22 adds newline, Pádraig Brady, 2014/12/01
- bug#19240: cut 8.22 adds newline, Bob Proulx, 2014/12/04
- bug#19240: cut 8.22 adds newline, John Kendall, 2014/12/04
- bug#19240: cut 8.22 adds newline, Paul Eggert, 2014/12/04
- bug#19240: cut 8.22 adds newline,
John Kendall <=
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/04
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/04
- bug#19240: cut 8.22 adds newline, John Kendall, 2014/12/04
- bug#19240: cut 8.22 adds newline, Bob Proulx, 2014/12/04
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/04
- bug#19240: cut 8.22 adds newline, Bob Proulx, 2014/12/04
- bug#19240: cut 8.22 adds newline, Bob Proulx, 2014/12/04
- bug#19240: cut 8.22 adds newline, Eric Blake, 2014/12/04
- bug#19240: cut 8.22 adds newline, Bob Proulx, 2014/12/04