summaryrefslogtreecommitdiff
path: root/lib/custom_command.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/custom_command.tcl')
-rw-r--r--[-rwxr-xr-x]lib/custom_command.tcl48
1 files changed, 10 insertions, 38 deletions
diff --git a/lib/custom_command.tcl b/lib/custom_command.tcl
index 63a42c5..6a5393f 100755..100644
--- a/lib/custom_command.tcl
+++ b/lib/custom_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 #
@@ -29,6 +32,7 @@
# --------------------------------------------------------------------------
# Initialize
+encoding system {utf-8}
package require Tk
wm withdraw .
wm command . "$argv0 $argv"
@@ -42,41 +46,9 @@ wm client . [info hostname]
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 {
return 1
}
@@ -89,8 +61,8 @@ while {![eof stdin]} {
}
# Execute loaded command
-if {[catch {exec /bin/sh << $cmd} result]} {
- secure_send [lindex $argv 0] ::X::custom_cmd_error [lindex $argv 1] "{" [regsub -all {[\{\}]} $result {\\&}] "}"
+if {[catch {exec bash << $cmd} result] && ![string equal $::errorCode NONE]} {
+ secure_send [lindex $argv 0] ::X::custom_cmd_error [lindex $argv 1] "{" [regsub -all {[\{\}]} $result {\\&}] "}"
} else {
secure_send [lindex $argv 0] ::X::custom_cmd_finish [lindex $argv 1] "{" [regsub -all {[\{\}]} $result {\\&}] "}"
}