]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/console.pm
Simplify the configure cache file format.
[user/henk/code/inspircd.git] / make / console.pm
index 045df8a704c61afd2b6e15c398df597c0447e4c7..621de0274293815f8c5bcbd728310ea3d41b4d2e 100644 (file)
 package make::console;
 
 BEGIN {
-       require 5.8.0;
+       require 5.10.0;
 }
 
+use feature ':5.10';
 use strict;
 use warnings FATAL => qw(all);
 
@@ -55,7 +56,7 @@ sub __console_format($$) {
 
 sub print_format($;$) {
        my $message = shift;
-       my $stream = shift || *STDOUT;
+       my $stream = shift // *STDOUT;
        while ($message =~ /(<\|(\S+)\s(.+?)\|>)/) {
                my $formatted = __console_format $2, $3;
                $message =~ s/\Q$1\E/$formatted/;
@@ -87,12 +88,8 @@ sub prompt_dir($$$;$) {
                $answer = rel2abs(prompt_string($interactive, $question, $default));
                $create = prompt_bool($interactive && !-d $answer, "$answer does not exist. Create it?", 'y');
                if ($create && $create_now) {
-                       my $mkpath = eval {
-                               mkpath($answer, 0, 0750);
-                               return 1;
-                       };
-                       unless (defined $mkpath) {
-                               print_warning "unable to create $answer!\n";
+                       unless (create_directory $answer, 0750) {
+                               print_warning "unable to create $answer: $!\n";
                                $create = 0;
                        }
                }
@@ -106,7 +103,7 @@ sub prompt_string($$$) {
        print_format "$question\n";
        print_format "[<|GREEN $default|>] => ";
        chomp(my $answer = <STDIN>);
-       print "\n";
+       say '';
        return $answer ? $answer : $default;
 }