abw / Template2

Perl Template Toolkit v2
http://template-toolkit.org/
146 stars 94 forks source link

ttree asks to create config file even when "--file=FILE" command line option is specified #282

Open KenNeighbors opened 4 years ago

KenNeighbors commented 4 years ago

Reproduce bug:

mkdir /tmp/src /tmp/dest
touch /tmp/cfg
ttree --file=/tmp/cfg --src=/tmp/src --dest=/tmp/dest
Do you want me to create a sample '.ttreerc' file for you?
(file: /home/ken/.ttreerc)   [y/n]: n

Expected behavior:

ttree -f /tmp/cfg -s /tmp/src -d /tmp/dst

(no question asked about creating config file)

*Fix bug by adding "--file=." to regex on line 47 in ttree:**

--- ttree.orig  2020-09-16 09:52:47.256298488 -0700
+++ ttree   2020-09-16 10:14:47.011793186 -0700
@@ -44,7 +44,7 @@

 # offer create a sample config file if it doesn't exist, unless a '-f'
 # has been specified on the command line
-unless (-f $RCFILE or grep(/^(-f|-h|--help)$/, @ARGV) ) {
+unless (-f $RCFILE or grep(/^(-f|--file=.*|-h|--help)$/, @ARGV) ) {
     print("Do you want me to create a sample '.ttreerc' file for you?\n",
       "(file: $RCFILE)   [y/n]: ");
     my $y = <STDIN>;