1#!/usr/local/bin/tclsh 2# -*- tcl -*- 3# this one needs no path. 4# fixes the '#!... path' for the given script 5 6#argv = {tclsh_path wish_path appscript} 7foreach {tclsh_path wish_path appscript} $argv {break;} 8 9 10set fail [catch {set fin [open $appscript r]}] 11if {$fail} { 12 # appscript does not exist 13 exit 1 14} 15 16 17if {[gets $fin ipPath] < 0} { 18 # appscript is empty 19 exit 2 20} 21 22 23if {![regexp {^#!} $ipPath]} { 24 # appscript is no application 25 close $fin 26 exit 3 27} 28 29 30if {[regexp {wish} $ipPath]} { 31 # wish application 32 33 if {{} == $wish_path} { 34 # wish was not found 35 exit 5 36 } 37 38 set fout [open $appscript.[pid] w] 39 puts $fout "#!$wish_path" 40 fcopy $fin $fout 41 42 close $fin 43 close $fout 44 45 file rename -force $appscript.[pid] $appscript 46 exit 0 47} 48 49 50if {[regexp {tclsh} $ipPath]} { 51 # tclsh application 52 53 if {{} == $wish_path} { 54 # tclsh was not found 55 exit 6 56 } 57 58 set fout [open $appscript.[pid] w] 59 puts $fout "#!$tclsh_path" 60 fcopy $fin $fout 61 62 close $fin 63 close $fout 64 65 file rename -force $appscript.[pid] $appscript 66 exit 0 67} 68 69# appscript is no tclsh/wish application 70exit 4 71