diff options
author | Bodo Möller <bodo@openssl.org> | 1999-06-07 17:33:50 +0400 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 1999-06-07 17:33:50 +0400 |
commit | 6576774b51d50acd12174dbdc3f6b01df953a516 (patch) | |
tree | f4ffa2e25cd2084c7b4d031d2bc050c6444f2fa6 /util | |
parent | 861b0ddd273b966783ed1c1e97b3f63760013341 (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')
-rwxr-xr-x | util/mkdir-p.pl | 33 |
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"; +} |