summaryrefslogtreecommitdiffstats
path: root/util/mkdir-p.pl
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>1999-06-07 13:33:50 +0000
committerBodo Möller <bodo@openssl.org>1999-06-07 13:33:50 +0000
commit6576774b51d50acd12174dbdc3f6b01df953a516 (patch)
treef4ffa2e25cd2084c7b4d031d2bc050c6444f2fa6 /util/mkdir-p.pl
parent861b0ddd273b966783ed1c1e97b3f63760013341 (diff)
mkdir -p is not fully portable (according to Marc Crispin,
NeXTstep creates a directory called -p); now mkdir-p.pl does its job.
Diffstat (limited to 'util/mkdir-p.pl')
-rwxr-xr-xutil/mkdir-p.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/mkdir-p.pl b/util/mkdir-p.pl
new file mode 100755
index 0000000000..2c003d6e84
--- /dev/null
+++ b/util/mkdir-p.pl
@@ -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";
+}