bug#75806: Trailing spaces; pattern "\s" before "[[:cntrl:]]" faulty

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Sat Jan 25 20:42:02 GMT 2025


On 2025-01-25 12:31, Paul Eggert via Cygwin wrote:
> On 2025-01-24 05:27, Andreas BROCKMANN via Bug reports for GNU grep wrote:
>> The 1st command below correctly reports trailing spaces, for Unix and Windows 
>> format files.
>> The 2nd one incorrectly reports all lines.
>>
>>    grep -sHn -i " [[:cntrl:]]*$" *.vhd
>>    grep -sHn -i "\s[[:cntrl:]]*$" *.vhd
> 
> I don't see a bug. The latter command is equivalent to:
> 
>     grep -Hins '[[:space:]][[:cntrl:]]*$' *.vhd
> 
> and if the input files use Microsoft CRLF format then [[:space:]] matches the CR 
> at the end of every line and [[:cntrl:]]* matches the empty string after the CR.
> 
> Possibly you need to use Unix LF format, or use the --text option, or something 
> like that.
> 
> Marking the bug as done.

IIRC even Cygwin dropped Windows text handling in coreutils, findutils, grep, 
sed, etc. about 2018 to be consistent with other POSIX platforms.

Use d2u/dos2unix or u2d/unix2dos in pipes to convert, or equivalent, such as
tr -d '\r', sed -e 's/\r//g', awk -e '{gsub(/\r/,"")'.

Cygwin users may be able to compensate by remounting the filesystem with a 
"text" mount option -o text or the equivalent in an /etc/fstab entry, but I am 
unsure if anyone has tested using that option nowadays.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin mailing list