Добавлена проверка параметров вызова файл или просто строка

This commit is contained in:
svkalinin 2022-11-18 13:22:29 +03:00
parent e7c1cbbbe1
commit 5c605d6907

View File

@ -1084,14 +1084,16 @@ if {$argc > 1} {
puts "Usage: $argv0 <sampleFile>" puts "Usage: $argv0 <sampleFile>"
} elseif {$argc == 1} { } elseif {$argc == 1} {
set filename [lindex $argv 0] set filename [lindex $argv 0]
if [file exists $filename] {
set file [open $filename] set file [open $filename]
set data [read $file [file size $filename]] set data [read $file [file size $filename]]
close $file close $file
# memorize location # memorize location
set regexp::data(v:dir) [file dirname $filename] set regexp::data(v:dir) [file dirname $filename]
set regexp::data(v:file) [file tail $filename] set regexp::data(v:file) [file tail $filename]
} else {
set data [lindex $argv 0]
}
regexp::sample:set $data regexp::sample:set $data
unset data unset data
} }
@ -1366,4 +1368,3 @@ proc make-regexp::make-regexp {words} {