git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-svn: handle leading/trailing whitespace from svnsync revprops

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Jan 12, 2008, 09:55 UTC
Message-ID
<20080112095505.GA5681@atjola.homenet>
In-Reply-To
<20080112091242.GA27109@soma>
On 2008.01.12 01:12:42 -0800, Eric Wong wrote:
Show 21 quoted lines
> Junio C Hamano <gitster@pobox.com> wrote:
> > Is it only me who finds that
> > 
> > 	($var) = ($var =~ m{^(any regexp)$}) or die "message"
> > 
> > is extremely a roundabout and hard-to-read way to say:
> > 
> > 	if ($var !~ m{^(the same regexp)$} {
> >         	die "message";
> > 	}
> > 
> > which is much easier to read?
> 
> The statements are not equivalent, however.  I'd have to add
> 
> 	$var = $1;
> 
> too, because I needed to extract what was inside the ( ) since the '$'
> doesn't catch the trailing newline, either.  I also couldn't find any of
> the /sm, /m, /s switches useful for making '$' not accept the trailing
> newline, either.

The \z assertion will do, eg m/^foo\z/ will only match exactly "foo", not "foo\n". As it is a zero-width assertion, you can also write m/^foo\z$/ if you prefer that.

Björn
Previous: Eric WongNext: Junio C Hamano
Message 13 of 18 in “Odd number of elements in anonymous hash”
  1. Dennis SchriddeJan 8, 2008
  2. Junio C HamanoJan 8, 2008
  3. Dennis SchriddeJan 8, 2008
  4. Eric WongJan 10, 2008
  5. Dennis SchriddeJan 10, 2008
  6. Dennis SchriddeJan 10, 2008
  7. Junio C HamanoJan 10, 2008
  8. Dennis SchriddeJan 10, 2008
  9. Junio C HamanoJan 10, 2008
  10. git-svn: handle leading/trailing whitespace from svnsync revpropsEric Wong, Jan 12, 2008
  11. Junio C HamanoJan 12, 2008
  12. Eric WongJan 12, 2008
  13. Björn SteinbrinkJan 12, 2008
  14. Junio C HamanoJan 12, 2008
  15. Junio C HamanoJan 12, 2008
  16. Dennis SchriddeJan 12, 2008
  17. Eric WongJan 9, 2008
  18. Sam VilainJan 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.