bugmake - Bugs: bug #17245, $(notdir foo/) should return ....


bug #17245: $(notdir foo/) should return . instead of blank

Submitter:  None
Submitted:  Mon 31 Jul 2006 09:11:01 PM UTC
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  3.79.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup

Mon 08 Jun 2009 03:45:46 AM UTC, comment #2: 

The notdir function has been around for so many years now I'm not sure how reasonable it is to change it, even if the alternative is better.  How many thousands of makefiles have been written expecting notdir to work the way it does?

At any rate I'm marking this as an Enhancement.

Paul D. Smith <psmith>
Group administrator
Sun 31 Dec 2006 01:54:40 AM UTC, comment #1: 

Well, if you need such functionality, you can write your own function:

MyNotDir_1 = $(if $(patsubst %/,,$1),$(notdir $1),.)#OK
MyNotDir = $(foreach v,$1,$(call MyNotDir_1,$v))

Now, MyNotDir acts as you expect.

I've tested it on make 3.80 & make 3.81.

Of course, GNUmake should better add a new internal function for this, so that users like you don't have to bother adding his own functions.

Jun Chen <chjfth>
Mon 31 Jul 2006 09:11:01 PM UTC, original submission:  

Documentation for notdir says:

"A file name that ends with a slash becomes an empty string. This is unfortunate, because it means that the result does not always have the same number of whitespace-separated file names as the argument had; but we do not see any other valid alternative."

Wrong. $(notdir foo/) should return . (a period).

This way, $(dir name)/$(notdir name) = name always.

A path ending in / is only really valid if it is a directory. If it is a directory, then it contains . and .. so returning . should be valid if the original path was valid. And foo/./bar is the same as foo/bar unless a filesystem is screwed up.

So the . should be returned instead of nothing, to keep the number of filenames the same, and to allow join to rejoin them correctly.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by chjfth (Posted a comment)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-06-08 psmith Item GroupBug Enhancement

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code