#! /bin/sh # # Prefix the user's path with some other places where tclsh might reside, # then exec tclsh. # # next line is a comment to tcl, but not sh: \ P=$PATH ; for i in /opt/tcl* ; do P=$i/bin:$P ; done ; \ PATH=/opt/bin:$P ; export PATH ; exec tclsh $0 ${1+"$@"} # First collect aliases set is_csh 1 set shell csh set str "$env(USER):" foreach line [split [read -nonewline [open /etc/passwd r]] \n] { if {[regexp $str $line]} { set shell [lindex [split $line :] end] set is_csh [string match *csh $shell] } } if {$is_csh} { # C shell foreach line [split [exec $shell -s << "alias\n"] \n] { scan $line "%s%\[^\n]" word defn set Alias($word) [string trim $defn] } } else { # Bourne shell if {![catch {exec $shell -c "alias\n"} result]} { foreach line [split $result \n] { scan $line "alias %\[^=]=%\[^\n]" word defn set Alias($word) [string trim $defn] } } } set printpath 0 foreach prog $argv { # First check for aliases: set isaliased 0 if [info exists Alias($prog)] { puts "$prog:\taliased to [string trim $Alias($prog)]" set isaliased 1 } if [string match */* $prog] { set matches [glob -nocomplain $prog] } else { set matches {} foreach dir [split $env(PATH) :] { set matches [concat $matches [glob -nocomplain $dir/$prog]] } } if [llength $matches] { puts [join $matches \n] } elseif !$isaliased { set printpath 1 puts "$prog: Command not found." } } if $printpath { puts "Searched path:\n[split $env(PATH) :]" }