--- brag-1.4.1.orig/brag
+++ brag-1.4.1/brag
@@ -332,6 +332,7 @@
;# different newsgroups
variable combineServers 0 ;# Don't combine parts from different
;# servers
+ variable keepFileNames 0 ;# Don't keep original file names
variable getSingle 0 ;# If true, get single-part msgs, too
variable finishedThread 1 ;# Flag to signify that a thread is
;# ready for another task
@@ -443,6 +444,7 @@
variable password
variable combine
variable combineServers
+ variable keepFileNames
variable total
variable max
variable getSingle
@@ -508,6 +510,9 @@
"-C" {
set combineServers 1
}
+ "-k" {
+ set keepFileNames 1
+ }
"-A" {
incr i
loadAcceptFile [lindex $argList $i]
@@ -1220,26 +1225,32 @@
proc brag::getDestination {file dir subject} {
+ variable keepFileNames
+
# The message subject might be well formatted, so we gan get a good file
# name from it. Otherwise use the original file name
- regsub -all -- { - } $subject "|" subject
- regsub -all -- {y[eE]nc} $subject "" subject
- set fields [split $subject "|"]
- if {[llength $fields] > 1} {
- set base [lindex $fields end]
- if {[regexp {[0-9,]+ bytes} $base] || [regexp {[0-9,]+[KM]} $base]} {
- set base [lindex $fields [expr {[llength $fields] - 2}]]
- }
- regsub "\\(\\)|\\\[\\\]" $base "" base
- set base [file tail [string trim [string trim $base {~}]]]
+ if {$keepFileNames} {
+ set base $file
} else {
- set base [file tail [string trim $file {~}]]
+ regsub -all -- { - } $subject "|" subject
+ regsub -all -- {y[eE]nc} $subject "" subject
+ set fields [split $subject "|"]
+ if {[llength $fields] > 1} {
+ set base [lindex $fields end]
+ if {[regexp {[0-9,]+ bytes} $base] || [regexp {[0-9,]+[KM]} $base]} {
+ set base [lindex $fields [expr {[llength $fields] - 2}]]
+ }
+ regsub "\\(\\)|\\\[\\\]" $base "" base
+ set base [file tail [string trim [string trim $base {~}]]]
+ } else {
+ set base [file tail [string trim $file {~}]]
+ }
+ regsub -all -- { [0-9,]+ bytes} $base {} base
+ regsub -all -- { [0-9,]+[KM]B*} $base {} base
+ set base [string trim $base {"}]
+ regsub -all -- {[^a-zA-Z0-9_. ]} $base "_" base
}
- regsub -all -- { [0-9,]+ bytes} $base {} base
- regsub -all -- { [0-9,]+[KM]B*} $base {} base
- set base [string trim $base {"}]
- regsub -all -- {[^a-zA-Z0-9_. ]} $base "_" base
# If the file doesn't already exist in the destination directory,
# return it, otherwise create a unique name based on the original
@@ -1262,7 +1273,7 @@
puts stderr "brag - Grab multipart binaries from news server
Usage: brag \[-s server\] \[-P port\] \[-g group\] \[-l user\] \[-p pass\]
- \[-o dir\] \[-n n\] \[-q\] \[-u\] \[-c\] \[-C\] \[-X\]
+ \[-o dir\] \[-n n\] \[-q\] \[-u\] \[-c\] \[-C\] \[-k\] \[-X\]
\[-a pattern \[-a pattern\] ...\] \[-r pattern \[-r pattern\] ...\]
\[-A file\] \[-R file\] \[-t number\] \[ -m max \]
or
@@ -1280,6 +1291,7 @@
-u Save message subjects, too
-c Combine parts even if they are from different groups
-C Combine parts even if they are from different servers
+ -k Keep original filenames when possible
-X Process single-part messages, too
-a pattern Accept messages matching the pattern
-r pattern Reject messages matching the pattern
--- brag-1.4.1.orig/brag.1
+++ brag-1.4.1/brag.1
@@ -58,6 +58,10 @@
.I ".sub"
extension added
.TP
+.I "-k"
+Keep original file names when possible, only rename when necessary to
+avoid a collission with existing files
+.TP
.I "\-o dir"
Set output directory to
.I "dir"