diff options
author | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
commit | 47aa8b00b2b11df13a100489e0f904a4947177ef (patch) | |
tree | b35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/external_command.tcl | |
parent | 5b8466f7fae0e071c0f4eda13051c93313910028 (diff) |
Import Upstream version 1.4.7
Diffstat (limited to 'lib/external_command.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/external_command.tcl | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/lib/external_command.tcl b/lib/external_command.tcl index 959cd29..552a73a 100755..100644 --- a/lib/external_command.tcl +++ b/lib/external_command.tcl @@ -1,8 +1,11 @@ -#!/usr/bin/tclsh +#!/bin/sh +# the next line restarts using wish \ +exec tclsh "$0" "$@" + # Part of MCU 8051 IDE ( http://mcu8051ide.sf.net ) ############################################################################ -# Copyright (C) 2007-2009 by Martin Ošmera # +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # This program is free software; you can redistribute it and#or modify # @@ -21,6 +24,11 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ +# >>> File inclusion guard +if { ! [ info exists _EXTERNAL_COMMAND_TCL ] } { +set _EXTERNAL_COMMAND_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Send input read from strandard input to certain Tk application via @@ -36,12 +44,13 @@ # -------------------------------------------------------------------------- # Initialize +encoding system {utf-8} package require Tk wm withdraw . wm command . "$argv0 $argv" wm client . [info hostname] -# Partse agruments +# Parse agruments set target_app [lindex $argv 0] set final_cmd [lindex $argv 1] set line_cmd [lindex $argv 2] @@ -69,39 +78,8 @@ if {$::MICROSOFT_WINDOWS} { proc secure_send args { if {[catch { eval "send $args" - } result]} { - puts "Unknown IO Error :: $result" - tk_messageBox \ - -title "Unknown IO Error" \ - -icon error \ - -type ok \ - -message "$result" - - if {[ \ - tk_messageBox \ - -title "X server security workaround" \ - -icon warning \ - -type yesno \ - -message "If the error was related to X server security, it is possible to temporarily workaround it by running this command: \"/bin/sh << 'for i in `xhost`; do xhost -\$i; done'\"\n\nDo you want to do it ?" - ] == {yes}} then { - catch { - exec -- /bin/sh << {xhost -; for i in `xhost`; do xhost -$i; done} - } - } else { - exit 1 - } - - if {[catch { - eval "send $args" - }]} { - tk_messageBox \ - -title "Workaround failed" \ - -icon error \ - -type ok \ - -message "Sorry this doesn't work ...\nIt's a strange bug somewhere in your operating system" - exit 1 - } - + } result]} then { + puts stderr "Unknown IO Error :: $result" return 1 } else { @@ -119,7 +97,7 @@ if {$line_cmd == {}} { if {!${::MICROSOFT_WINDOWS}} { secure_send $target_app $final_cmd "{" [regsub -all {[\{\}]} $result {\\&}] "}" - } { + } else { dde eval $target_app $final_cmd "{ [regsub -all {[\{\}]} $result {\\&}] }" } @@ -128,16 +106,20 @@ if {$line_cmd == {}} { while {![eof stdin]} { if {!${::MICROSOFT_WINDOWS}} { secure_send $target_app $line_cmd "{" [regsub -all {[\{\}]} [gets stdin] {\\&}] "}" - } { + } else { dde eval $target_app $line_cmd "{ [regsub -all {[\{\}]} [gets stdin] {\\&}] }" } } if {!${::MICROSOFT_WINDOWS}} { secure_send $target_app $final_cmd - } { + } else { dde eval $target_app $final_cmd } } exit 0 + +# >>> File inclusion guard +} +# <<< File inclusion guard |