Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mkdir -pv not verbose

Tags:

bash

macos

mkdir

If I run mkdir -pv, the -p works, but I do not get verbose output; however, if I run just mkdir -v, the verbose output appears as expected. Also potentially of note, the longform of -v does not seem to work at all.

From my testing: mkdir -p a/b/c: creates a/, a/b/, and a/b/c/, gives no output to terminal (as expected)

mkdir -v d: creates d/ and outputs mkdir: created directory 'd' (as expected)

mkdir -pv e/f/g: creates e/, e/f/, and e/f/g/, gives no output to terminal (why?)

mkdir --verbose h: gives a illegal option -- - error (why?)


Update: I filed a bug report with Apple for this issue, and received the following reply:

enter image description here

Their answer that "-v is not applicable" does not make much sense to me, since mkdir -v works just fine, but since there are various workarounds and I am no longer even using OSX, I don't think it's worth pursuing any further to me.

like image 671
SnoringFrog Avatar asked Feb 04 '15 19:02

SnoringFrog


1 Answers

Macs use BSD-based code that is (mostly) POSIX compliant but (mostly) without GNU extensions (such as double-dash long options). The man page does document -v and -p, and -p works but does seem to suppress the -v option (which is probably when it is most useful).

One of your options is to file a bug with the Darwin or BSD teams, or with Apple. That's the way it is; it is arguably not the way it should be. (GNU mkdir supports -v and prints the directories it creates when used with -p, which makes more sense, and supports the 'it is a bug' contention.)

With thanks to SnoringFrog:

Another option is to install and use the GNU mkdir command on OSX. It is part of GNU coreutils and you could install it as explained in How to replace Mac OS X utilities with GNU core utilities at Ask Different. Then, you could alias mkdir to point to gmkdir to get the expected behavior (assuming you don't use --default-names when installing the GNU tools).

like image 106
Jonathan Leffler Avatar answered Oct 17 '22 23:10

Jonathan Leffler