Subject: Fix warnings if no template directory exists
Forwarded: no
Author: James McCoy <jamessan@debian.org>
Bug-Debian: https://bugs.debian.org/1086943
---
diff --git i/vimplate/bin/vimplate w/vimplate/bin/vimplate
index 563972d..bffa9a3 100755
--- i/vimplate/bin/vimplate
+++ w/vimplate/bin/vimplate
@@ -206,6 +206,16 @@ if ( defined $opt{createconfig} ) {
   }
 }
 
+=item B<-dir|d=<templatedir>>
+
+Search templatefiles in <templatedir>.
+
+=cut
+
+if ( defined $opt{dir} ) {
+  $Config::opt->{dir}=$opt{dir}
+}
+
 =item B<-listtemplate>
 
 Print the avaible templates and exit.
@@ -213,7 +223,7 @@ Print the avaible templates and exit.
 =cut
 
 sub listTemplates {
-  opendir(DIR, $Config::opt->{dir});
+  return unless exists $Config::opt->{dir} and opendir(DIR, $Config::opt->{dir});
   my ($file, @files);
   FILE: foreach $file (readdir(DIR)) {
     next FILE if ($file!~/\.tt$/);
@@ -252,16 +262,6 @@ if ( defined $opt{user} ) {
   $Config::opt->{user}=$opt{user}
 }
 
-=item B<-dir|d=<templatedir>>
-
-Search templatefiles in <templatedir>.
-
-=cut
-
-if ( defined $opt{dir} ) {
-  $Config::opt->{dir}=$opt{dir}
-}
-
 =item B<-template=<templatefile>>
 
 Use the <templatefile>.
