Almost two years ago, one of the very first patches submitted to the dirvish archive was a fix by Eric Mountain that allowed tree names to have spaces in them. Spaces in names are possible with unix, but are much more common with windows.
On the wiki, R. Fried pointed out that Eric's fix breaks the regular behavior - it removes the last character of the source tree when there are both sourcetree and aliastree fields . R. Fried suggested removing the patch, which breaks the behavior Eric wants. Here is a patch that hopefully meets both needs, which is described at the end of http://wiki.dirvish.org/index.cgi?SpacesInSource The 1.2.0 behavior by jwschultz looked like so: ($srctree, $aliastree) = split(/\s+/, $$Options{tree}) or seppuku 228, "ERROR: no source tree defined"; $srctree =~ s(/+$)(); $aliastree =~ s(/+$)(); $aliastree ||= $srctree; The 1.2.1 patch by Eric (the current version) looks like: ($srctree, $aliastree) = split(/[^\\]\s+/, $$Options{tree}) or seppuku 228, "ERROR: no source tree defined"; $srctree =~ s(\\ )( )g; $srctree =~ s(/+$)(); $aliastree =~ s(/+$)(); $aliastree ||= $srctree; My suggested patched behavior looks like: $_ = $$Options{tree} ; s/(\s)/\\$1/g; # These two lines swap the escaped spaces with s/\\\\//g; # the nonescaped ones. s/(\\\s)+/$1/g; # replace multiple separators with only one ($srctree,$aliastree) = split /\\\s/ or seppuku 228, "ERROR: no source tree defined"; $aliastree ||= $srctree; For you non-Perl programmers ( which includes me 29 days per month ) the new behavior manipulates the spaces before the split, turning escaped spaces into simple spaces, and simple spaces into escaped spaces. Duplicate escaped spaces are removed, and *then* we do the split. Quite a cheesy hack, but it allows both the original "source and alias" behavior to work, and also the escaped whitespace behavior that Eric wanted to work. In addition, it allows alternate white space characters (like tab) to be preserved in weird directory names, and also allows escaped whitespace on the beginning or end of directory names. Whitespace on the beginning or end of directory names is evil, but is permitted in some circumstances and we should allow for it. This also silently discards extraneous fields after the second field, matching the behavior of earlier versions of dirvish. I built a test script and fed it a few examples: ---------------------- input>AA BB< srctree>AA< aliastree>BB< ---------------------- input>AA BB CC DD< srctree>AA< aliastree>BB< ---------------------- input>AA\ BB CC DD< srctree>AA BB< aliastree>CC< ---------------------- input>AA\ BB CC\ DD< srctree>AA BB< aliastree>CC < ---------------------- input>AA\ \ BB\ \ CC < srctree>AA < aliastree> BB CC< ---------------------- input>< ERROR: no source tree defined ---------------------- Ponder this patch. There is probably an easier way. I plan to put it into the 1.3.X, which I have neglected for a long time but plan to work on this weekend. I could use some help, BTW, we need better programmers working on dirvish! Keith -- Keith Lofstrom [EMAIL PROTECTED] Voice (503)-520-1993 KLIC --- Keith Lofstrom Integrated Circuits --- "Your Ideas in Silicon" Design Contracting in Bipolar and CMOS - Analog, Digital, and Scan ICs _______________________________________________ Dirvish mailing list [email protected] http://www.dirvish.org/mailman/listinfo/dirvish
