Re: [PATCH] mk: don't escape '#' for `grep`

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

 



Hi Jakub,

On Thu, Feb 27, 2025 at 05:28:00PM +0100, Jakub Wilk wrote:
> * Alejandro Colomar <alx@xxxxxxxxxx>, 2025-02-27 16:20:
> > >   Now this latter will resolve to "\#".  If you want to write makefiles
> > >   portable to both versions, assign the number sign to a variable:
> > >     H := \#
> > >     foo := $(shell echo '$H')
> 
> Alternatively, you could take advantage of the fact that in some shell
> contexts # and \# mean the same thing:
> 
>   foo := $(shell echo ''\#)

Hmmm, sounds reasonable, since a # not preceeded by a space is not a
comment.

	alx@debian:~$ echo ''\#
	#
	alx@debian:~$ echo ''#
	#

I'll take this workaround.  I'll put this on the commit:

	Reported-by: Sergei Trofimovich <slyich@xxxxxxxxx>
	Cc: Florian Weimer <fw@xxxxxxxxxxxxx>
	Cc: Boris Pigin <boris.pigin@xxxxxxxxx>
	Suggested-by: Jakub Wilk <jwilk@xxxxxxxxx>

> 
> > The thing is, on my system, grep(1) is just fine with that escaped hash:
> > 
> > 	$ echo '#foo' | grep '\#foo'
> > 	#foo
> 
> The warning comes from GNU grep (>= 3.8): "Regular expressions with stray
> backslashes now cause warnings, as their unspecified behavior can lead to
> unexpected results."
> 
> You're probably not seeing the warnings because Debian patched them out:
> https://bugs.debian.org/1019724

Ahhh, that makes sense.  Thanks!


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux