SA Bugzilla – Bug 1491
~/ replacement in ArchiveIterator?
Last modified: 2003-02-16 22:00:14 UTC
Shouldn't there be an ^ in there? Sorry, cut-and-pasted diff, but this one is easy. diff -u -r1.27 ArchiveIterator.pm --- lib/Mail/SpamAssassin/ArchiveIterator.pm 1 Feb 2003 17:06:33 -0000 1.27 +++ lib/Mail/SpamAssassin/ArchiveIterator.pm 17 Feb 2003 08:46:32 -0000 @@ -437,7 +437,7 @@ my ($self, $path) = @_; # fix home dir: ~ = /home/jm - $path =~ s/\~/$ENV{'HOME'}/g; + $path =~ s/^\~/$ENV{'HOME'}/; # fix csh-style globs: * = er, you know what it does ;) my @paths = glob $path;
At least can't I see any reason to replace every tilde in the path with $HOME. I changed it and also added escaping for white spaces in paths (most of my folders contain white spaces).
Malte, I think you missed my point: code review, being circumspect about making changes during freeze, etc. Anyway, just note that the current escaping code doesn't handle odd cases like backslashed backslashes (handling spaces is a higher priority). I do, however, like the slightly more elegant: s/(?<!\\)(\s)/\\$1/g; Yeah, I'm showing off, but you asked for it. Hmmm... or did I ask for it by not assigning the bug to myself? Whatever... :-) - Dan
Got the point, but do you think code review is really important in thise obvious case? I can't see _any_ good reason to have ~/Mail/Almost~There replaced with /home/mss/Mail/Almosthome/mssThere. ;-) For the escaping, I first wanted to use the look-behind RE but then I faintly remembered something about problems with either look-behind or look-ahead in Perl 5.005. It was either not implemented or very expensive. As I did not want to grep through the old docs, I took the unelegant way. Oh, and whoever wants to use backslashes in front of spaces in his paths should maybe think about his naming scheme :o)
Subject: Re: [SAdev] ~/ replacement in ArchiveIterator? I'm a little worried about the 'escaping spaces' change. What's the purpose of it? Surely perl does not care if the spaces are escaped in paths used internally, and in the mass-check output, spaces are replaced by underscores anyway. Does the glob function require that spaces be escaped? (in that case the change makes sense.) BTW I've just tested with a space-containing dir, and "mass-check" seems to work OK with it, mind you -- so it *seems* good. I'm just paranoid at this late stage! --j.
Subject: Re: ~/ replacement in ArchiveIterator? > I'm a little worried about the 'escaping spaces' change. What's the > purpose of it? Surely perl does not care if the spaces are escaped in > paths used internally, and in the mass-check output, spaces are replaced > by underscores anyway. > > Does the glob function require that spaces be escaped? (in that case > the change makes sense.) Yeah, that's basically why I gave Malte a bit of a hard time. I had to look into the change to understand why it was necessary, so it was (in my book), a big enough of a change to require a bit more explanation and review during our freeze. Incidentally, I've been using the tilde change for several weeks (on the back burner, so to speak), so I wasn't too worried about it, but I did want to run it by someone else (which I did). Anyway, yes, "glob" evidently requires that spaces be escaped. News to me too. - Dan
File::Glob globs like the shell does: Spaces separate files. So an entry like spam:mbox:~/.Mail/My Spam will make mass-check look for the files "~/Mail/My" and "Spam". Somebody checked in the glob code shortly before the big mass-check and I just started my check overnight, discovering the next morning that all I got was an error complainig about a missing dir. That's why I went and fixed this one (I got the RE already in my copy of the ArchiveIterator) because I was pretty pissed back then.
Subject: Re: [SAdev] ~/ replacement in ArchiveIterator? > ------- Additional Comments From ajmawer@optusnet.com.au oh FFS. ;) That's jm@jmason.org BTW.
Subject: Re: ~/ replacement in ArchiveIterator? ajmawer@optusnet.com.au writes: > oh FFS. ;) That's jm@jmason.org BTW. I've been wondering about that, but hadn't quite brought myself to ask if it was really you. - Dan