helper/command: do not replace new commands with ocd_ prefix
[fw/openocd] / src / helper / startup.tcl
1 # Defines basic Tcl procs that must exist for OpenOCD scripts to work.
2 #
3 # Embedded into OpenOCD executable
4 #
5
6 # Try flipping / and \ to find file if the filename does not
7 # match the precise spelling
8 proc find {filename} {
9         if {[catch {ocd_find $filename} t]==0} {
10                 return $t
11         }
12         if {[catch {ocd_find [string map {\ /} $filename} t]==0} {
13                 return $t
14         }
15         if {[catch {ocd_find [string map {/ \\} $filename} t]==0} {
16                 return $t
17         }
18         # make sure error message matches original input string
19         return -code error "Can't find $filename"
20 }
21 add_usage_text find "<file>"
22 add_help_text find "print full path to file according to OpenOCD search rules"
23
24 # Find and run a script
25 proc script {filename} {
26         uplevel #0 [list source [find $filename]]
27 }
28 add_help_text script "filename of OpenOCD script (tcl) to run"
29 add_usage_text script "<file>"
30
31 #########
32