This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using ecosadmin.tcl with the latest Cygwin Tcl shell


The best solution I can find to the generic problem of invoking a Tcl
script directly from (say) a bash shell while preserving both spaces
in command-line arguments and null arguments uses commands of the form:

  exec tclsh \"${0}\" ${1+\"${1}\"} ${2+\"${2}\"} ${3+\"${3}\"} ${4+\"${4}\"} ${5+\"${5}\"}

The above will faithfully process a script invocation such as:

   bash$ ./my\ script.tcl arg1 arg\ 2 "" arg4

There should be at least one more argument listed than the maximum
number expected in order for the executed Tcl script to detect "too
many arguments" correctly.

I will tweak the Tcl scripts accordingly.

The 'cygpath' processing added by Tim Michals' patches is useful but
should be undertaken in the body of the Tcl script, not here. Otherwise,
the behaviour of the Tcl script when invoked directly from (say) a
bash shell will differ from that when invoked as a command line argument
of the Tcl shell. The appended patch accommodates UNIX-style paths when
adding an eCos package under Cygwin.

John Dallaway

-----Original Message-----
From: Jonathan Larmour
Date: Friday 24 Jan 2003 19:35
Subject: Re: Using ecosadmin.tcl with the latest Cygwin Tcl shell

> John Dallaway wrote:
> > The net distribution of Cygwin now ships with tclsh83.exe rather
> > than cygtclsh80.exe. This patch updates the #! magic in the eCos
> > command-line admin tool to work with the new Tcl shell. Operation
> > with older shells should not be affected.
>
> John, we already got a (slightly different) patch from Tim Michals
> earlier. I assumed you were going to look at that. Please verify that
> quoting is not an issue, presumably with paths with spaces in.
>
> And you need to tweak more files (see Tim's mail).
> http://sources.redhat.com/ml/ecos-patches/2003-01/msg00052.html
>
> Jifl


--cut here--

===================================================================
RCS file: /cvs/ecos/ecos/packages/ecosadmin.tcl,v
retrieving revision 1.11
diff -u -5 -r1.11 ecosadmin.tcl
--- ecosadmin.tcl	24 Jan 2003 16:58:47 -0000	1.11
+++ ecosadmin.tcl	27 Jan 2003 09:39:05 -0000
@@ -1,15 +1,15 @@
 #!/bin/sh
-# these lines restart using the tcl shell \
+# these lines restart using the Tcl shell \
   exec sh -c "if ( echo | tclsh ) 2>/dev/null ; then \
-      exec tclsh \"${0}\" ${1+${*}} ; \
+      exec tclsh \"${0}\" ${1+\"${1}\"} ${2+\"${2}\"} ${3+\"${3}\"} ${4+\"${4}\"} ${5+\"${5}\"} ; \
     elif ( echo | tclsh83 ) 2>/dev/null ; then \
-      exec tclsh83 \"${0}\" ${1+${*}} ; \
+      exec tclsh83 \"${0}\" ${1+\"${1}\"} ${2+\"${2}\"} ${3+\"${3}\"} ${4+\"${4}\"} ${5+\"${5}\"} ; \
     elif ( echo | cygtclsh80 ) 2>/dev/null ; then \
-      exec cygtclsh80 \"${0}\" ${1+${*}} ; \
+      exec cygtclsh80 \"${0}\" ${1+\"${1}\"} ${2+\"${2}\"} ${3+\"${3}\"} ${4+\"${4}\"} ${5+\"${5}\"} ; \
     else \
-      echo Could not find TCL interpreter ; \
+      echo Cannot find Tcl shell ; \
       exit 1 ; \
     fi"

 # {{{  Banner

@@ -465,16 +465,13 @@
 			# An unrecognised argument.
 			fatal_error "invalid argument $args($i)"
 		}
 	} 

-	# Under Windows it is desirable to do some checking on any directories that
-	# have been provided. Some cygwin pathnames that a user might supply are
-	# not acceptable to Tcl.
-	if { $ecosadmin::windows_host } {
-		set ecosadmin::component_repository [get_pathname_for_tcl $ecosadmin::component_repository]
-	}
+	# Convert user-specified UNIX-style Cygwin pathnames to Windows Tcl-style as necessary
+	set ecosadmin::component_repository [get_pathname_for_tcl $ecosadmin::component_repository]
+	set ecosadmin::add_package [get_pathname_for_tcl $ecosadmin::add_package]
 }
 
 #
 # Display help information if the user has typed --help, -H, --H, or -help.
 # The help text uses two hyphens for consistency with configure.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]