On Wed 14 Feb 2018, Peter Lebbing wrote: > > This is because of the following snippet: > - --8<---------------cut here---------------start------------->8--- > #+SIS: KHL 2005-02-18 SpacesInSource fix > #-SIS: ($srctree, $aliastree) = split(/\s+/, $$Options{tree}) > ($srctree, $aliastree) = split(/[^\\]\s+/, $$Options{tree}) > or seppuku 228, "ERROR: no source tree defined"; > $srctree =~ s(\\ )( )g; #+SIS > $srctree =~ s(/+$)(); > - --8<---------------cut here---------------end--------------->8--- > > So what happened on the last example? The split statement splits the > string "/somewhere /alias" into the components: > First part: "/somewher" > Separator: "e " > Second part: "/alias" > > So the last character of the first part is gobbled as part of the > separator. Since an optional trailing slash is also removed, as long as > a trailing slash is used on the first part, everything still works. But > not including the trailing slash is a perfectly valid configuration. > > I don't know any Perl, so I don't know the correct way to fix this. I > had a quick look and didn't see it.
This can be solved with a "zero-width negative lookbehind assertion" (yes I needed the perlre manpage to look that up...). The split then becomes: split(/(?<![\\])\s+/, $$Options{tree}) The pattern matches a space only if preceded by a non-backslash character, and the pattern itself does not include it. I'll patch dirvish with this fix. Thanks, Paul