sqlite/tool/cp.tcl
drh ae5ef1e80f Fix the new tool/cp.tcl so that it works with older TCL versions, such as
jimtcl.

FossilOrigin-Name: 61f18c96183867fe9d0fb30b8b71c0253f40503e32c8a4202196fb6418f2f46e
2024-10-24 15:57:21 +00:00

29 lines
783 B
Tcl

#/usr/bin/tclsh
#
# This is a TCL script that copies multiple files into a common directory.
# The "cp" command will do this on unix, but no such command is available
# by default on Windows, so we have to use this script.
#
# tclsh cp.tcl FILE1 FILE2 ... FILEN DIR
#
# This should be as simple as
#
# file copy -force -- {*}$argv
#
# But jimtcl doesn't support that. So we have to do it the hard way.
if {[llength $argv]<2} {
error "Usage: $argv0 SRC... DESTDIR"
}
set n [llength $argv]
set destdir [lindex $argv [expr {$n-1}]]
if {![file isdir $destdir]} {
error "$argv0: not a directory: \"$destdir\""
}
for {set i 0} {$i<$n-1} {incr i} {
set fn [file normalize [lindex $argv $i]]
set tail [file tail $fn]
file copy -force $fn [file normalize $destdir/$tail]
}