mkdir(1) and the -p option

| No Comments | No TrackBacks
So I joined the upstream coreutils mailing list a few weeks back, because mkdir -p -m wasn't producing the desired results. I searched my almighty friend Google and couldn't come up with anything, so I assumed it was a bug and reported it upstream.

Well, as it turns out, it's not a bug, it's a requirement of the POSIX standard. But I couldn't find anything on Google about it, so I figured I'd post here so the someone may find it, since the same question was asked on the mailing list last week.

Basically, when you create directories with -p -m , only the last element has the desired mode. This is due to the above referenced standard, which states that the behavior of -p is to create the parent directories as defined by the current umask, adding write and execute permissions for the owner if he would not get them per the current umask, and finally to create the final directory with the specified mode.

Stupid standard, in my opinion, but hey, it's laid out right there in black and white. Above my pay grade to change it :)

No TrackBacks

TrackBack URL: http://blog.jds2001.org/cgi-bin/mt-tb.cgi/244

Leave a comment