abw/Template2

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

Opened this issue · 0 comments

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>;