Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mkdir -p is not fully portable (according to Marc Crispin,
NeXTstep creates a directory called -p); now mkdir-p.pl does its job.
- Loading branch information
Showing
2 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/local/bin/perl | ||
|
||
# mkdir-p.pl | ||
|
||
# On some systems, the -p option to mkdir (= also create any missing parent | ||
# directories) is not available. | ||
|
||
my $arg; | ||
|
||
foreach $arg (@ARGV) { | ||
&do_mkdir_p($arg); | ||
} | ||
|
||
|
||
sub do_mkdir_p { | ||
local($dir) = @_; | ||
|
||
$dir =~ s|/*$||; | ||
|
||
if (-d $dir) { | ||
return; | ||
} | ||
|
||
if ($dir =~ /\//) { | ||
local($parent) = $dir; | ||
$parent =~ s|[^/]*$||; | ||
|
||
do_mkdir_p($parent); | ||
} | ||
|
||
mkdir($dir, 0777) || die "Cannot create directory $dir: $!\n"; | ||
print "created directory $dir\n"; | ||
} |