TABLE OF CONTENTS
::pwtk::execute
SYNOPSIS
proc ::pwtk::execute {args} {
USAGE
execute ?switches? program ?arg1? ?arg2? ?arg3? ...
PURPOSE
A proc analogous to Tcl's exec, but searches for the "program" executable using the ::pwtk::findExecutable. The arguments are passed to exec verbatim.
ARGUMENTS
- switches -- switches to Tcl's exec command (-ignorestderr, -keepnewline, --)
- program -- name of executable to execute
- arg1, arg2... -- command-line arguments to supply to "program"
SOURCE
set options { {ignorestderr "Stops the exec command from treating the output of messages to the pipeline's standard error channel as an error case."} {keepnewline "Retains a trailing newline in the pipeline's output. Normally a trailing newline will be deleted."} } array set opt [::cmdline::getoptions args $options [list [lindex [info level 0] 0] options:]] if { $opt(ignorestderr) } { append execOpts "-ignorestderr " } if { $opt(keepnewline) } { append execOpts "-keepnewline " } append execOpts "--" set prog [findExecutable [lindex $args 0]] set args [lrange $args 1 end] if { $prog eq {} } { ::pwtk::error "cannot find the executable \"[lindex $args 0]\"" 1 } ::pwtk::print "Running: exec $execOpts $prog $args\n" return [exec {*}$execOpts $prog {*}$args] }