Bug in empty-dirs setting
(1) By anonymous on 2023-05-21 20:52:16 [source]
Hi there, I have uncovered a bug in the implementation of empty-dirs. The documentation states that this is either a comma-separated or newline-separated list. However, if I create an empty-dirs file in the .fossil-settings folder and populate it with a newline-separated list of folders where one folder may have spaces in it, then fossil will unfortunately create each multiple folders rather than the one folder, each folder being named for one of the words. For example, lets say I have the following line in my empty-dirs file: Test Folder/My Subfolder This will generate the following *three* top level folders: Test Folder Subfolder And inside "Folder" will be a folder named "My". It would be really, really great if this can be fixed so that folder names that contain spaces are properly supported. I'd even be happy if it meant escaping the space with a backslash (which doesn't currently work, in case anyone wonders) - that would be a perfect workaround keeping compatibility for anyone out there who has not read the documentation and has used space-separated lists. Many thanks, Andy
(2.1) By Warren Young (wyoung) on 2023-05-21 22:31:04 edited from 2.0 in reply to 1 [link] [source]
The routine that implements glob parsing (here) is way down in the guts of Fossil and affects a dozen other source code files. As you can see from its comment, the supported way of handling this is with single or double quotes.
"Fixing" it according to your wishes is a one-line change, but that one line hasn't changed in a decade, implying that there are a whole lot of users who now depend on the way it's worked ever since. Moreover, it was changed on purpose.
If quotes fix the spaces-in-file-name problem as documented, I'd rather we change the higher-level documentation to match what the core routine actually does than change the core routine and hope that doesn't break a bunch of stuff.
(3) By anonymous on 2023-05-22 18:15:48 in reply to 2.1 [link] [source]
Hi there, Thank you for your quick reply. Unfortunately quoting (single or double) is not a solution, so it looks like that has broken since the commit in question. I appreciate that it is probably too difficult to fix all this now. Therefore, please could you update the documentation to match actual behaviour to help any who follow in future. I will find another solution. Many thanks!
(4) By Warren Young (wyoung) on 2023-05-22 22:33:45 in reply to 3 [link] [source]
If you're willing to try the latest trunk, I believe I've solved this problem.
My prior reply blindly assumed that the
empty-dirs setting's value would be parsed by the same routine that parses the value for the
*-glob settings. The fix was to reify my assumption, since the glob parser does allow for quoted whitespace. I saw no reason why we should have two different, inconsistent parsers for lists of file names.