Menu

whitespace in file names

Help
giksos
2010-02-23
2013-03-15
  • giksos

    giksos - 2010-02-23

    Makepp seems to be much better than make in handling whitespace:
    'bla bla.x': 'bla bla.y'
    works. However, neither foreach nor % are whitespace-aware. Thus
    %.x: %.y
    doesn't capture the case above.

    Is there a plan to enhance Makepp to treat whitespace in filenames correctly?

     
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2010-02-25

    Dear giksos,

    in Gnu make this has an amazing 5 dependencies:

    all: 'foo foo.x' "bar bar.x" foo\ bar.x
    

    The single quotes just disappear leaving two filenames, the double quotes are part of their adjacent file name and only the backslash works as expected.  This differs from the Shell and Makepp which treats all three styles as equivalent.

    But, as you noticed, it doesn't help Gnu make, since a percent pattern rule doesn't match a file with a space, a bug it shares with makepp.

    The problem is that all processing is string based.  Quite wastefully each called function splits arguments on commas, splits lists on whitespace and joins the result with spaces to a string again.  Functions expecting a list of filenames unquote them for processing — the question is how to requote.  The clean way would be to remember what was quoted how, and to requote only the corresponding result the same way.  Everything else would lead to possible problems when the result is not passed to the Shell as a list but used differently, e.g.:

    FILENAME = funny "file name"
    all:
        cat '$(somefunction $(FILENAME))'
    

    How can somefunction consistently handle its argument's quoting without knowing it'll be quoted to the Shell?  Mixing Make and Shell syntax in a makefile is quite a headache!

    How does this relate to your problem?  Pattern rules are internally transformed to :foreach rules, where the list of applicable files grows as they are discovered.  The target is then determined via $(filesubst), with the problems described above.

    Is it really important that this work right, given that file names with spaces happen in Windows user applications, but are probably very rare in a programming environment?  And if you have just the odd one, explicit rules should work fine in Makepp.

    regards
    Daniel

     

Log in to post a comment.