public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* #! magic for finding Cygwin Tcl shell
@ 2009-01-06 18:02 John Dallaway
  2009-01-06 18:51 ` Jonathan Larmour
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: John Dallaway @ 2009-01-06 18:02 UTC (permalink / raw)
  To: ecos-devel

I was looking at support for UNC file paths in the eCos Configuration
Tool today. The convoluted #! magic we use in our Tcl scripts to find a
Cygwin Tcl shell is getting in the way when calling (eg) heapgen.tcl via
a UNC repository path. This code is only needed to support installations
of Cygwin that are more than 5 years old.

Rather than increase the complexity of the #! magic still further, I
think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
within our Tcl scripts. However, this would break compatibility with old
Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.

Any objections?

John Dallaway

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 18:02 #! magic for finding Cygwin Tcl shell John Dallaway
@ 2009-01-06 18:51 ` Jonathan Larmour
  2009-01-06 19:10   ` Gary Thomas
  2009-01-06 19:13   ` John Dallaway
  2009-01-06 20:01 ` Bart Veer
  2009-01-07 11:10 ` Tarmo Kuuse
  2 siblings, 2 replies; 13+ messages in thread
From: Jonathan Larmour @ 2009-01-06 18:51 UTC (permalink / raw)
  To: John Dallaway; +Cc: ecos-devel

John Dallaway wrote:
> I was looking at support for UNC file paths in the eCos Configuration
> Tool today. The convoluted #! magic we use in our Tcl scripts to find a
> Cygwin Tcl shell is getting in the way when calling (eg) heapgen.tcl via
> a UNC repository path. This code is only needed to support installations
> of Cygwin that are more than 5 years old.
> 
> Rather than increase the complexity of the #! magic still further, I
> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
> within our Tcl scripts. However, this would break compatibility with old
> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
> 
> Any objections?

Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
bits being dropped, but I'd still want it to be found from the PATH by some
means.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 18:51 ` Jonathan Larmour
@ 2009-01-06 19:10   ` Gary Thomas
  2009-01-06 19:44     ` Jonathan Larmour
  2009-01-06 19:13   ` John Dallaway
  1 sibling, 1 reply; 13+ messages in thread
From: Gary Thomas @ 2009-01-06 19:10 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: John Dallaway, ecos-devel

Jonathan Larmour wrote:
> John Dallaway wrote:
>> I was looking at support for UNC file paths in the eCos Configuration
>> Tool today. The convoluted #! magic we use in our Tcl scripts to find a
>> Cygwin Tcl shell is getting in the way when calling (eg) heapgen.tcl via
>> a UNC repository path. This code is only needed to support installations
>> of Cygwin that are more than 5 years old.
>>
>> Rather than increase the complexity of the #! magic still further, I
>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
>> within our Tcl scripts. However, this would break compatibility with old
>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
>>
>> Any objections?
> 
> Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
> bits being dropped, but I'd still want it to be found from the PATH by some
> means.

Does CygWin have '/usr/bin/env'?  This is the "modern" way
to handle this:

 #! /usr/bin/env tclsh
 ...


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 18:51 ` Jonathan Larmour
  2009-01-06 19:10   ` Gary Thomas
@ 2009-01-06 19:13   ` John Dallaway
  2009-01-06 19:37     ` Jonathan Larmour
  1 sibling, 1 reply; 13+ messages in thread
From: John Dallaway @ 2009-01-06 19:13 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: ecos-devel

Hi Jifl

Jonathan Larmour wrote:

>> Rather than increase the complexity of the #! magic still further, I
>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
>> within our Tcl scripts. However, this would break compatibility with old
>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
>>
>> Any objections?
> 
> Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
> bits being dropped, but I'd still want it to be found from the PATH by some
> means.

Have you ever encountered a Linux system where tclsh is not accessible
at /usr/bin/tclsh? Or were you thinking of portability to other
operating systems?

I note your (old) post to the Cygwin list which implies that
/usr/bin/tclsh is usual for UNIX-like operating systems:

  http://cygwin.com/ml/cygwin/2003-02/msg00007.html

John Dallaway

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 19:13   ` John Dallaway
@ 2009-01-06 19:37     ` Jonathan Larmour
  2009-01-06 20:04       ` Sergei Gavrikov
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Larmour @ 2009-01-06 19:37 UTC (permalink / raw)
  To: John Dallaway; +Cc: ecos-devel

John Dallaway wrote:
> Hi Jifl
> 
> Jonathan Larmour wrote:
> 
>>> Rather than increase the complexity of the #! magic still further, I
>>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
>>> within our Tcl scripts. However, this would break compatibility with old
>>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
>>>
>>> Any objections?
>> Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
>> bits being dropped, but I'd still want it to be found from the PATH by some
>> means.
> 
> Have you ever encountered a Linux system where tclsh is not accessible
> at /usr/bin/tclsh? Or were you thinking of portability to other
> operating systems?

Portability (or a linux system where tclsh was not installed by the system
owner - not everyone's environment is their own desktop). Command line
stuff needs to work more widely than Linux. tclsh in /usr/local/bin or the
user's home dir or ...

> I note your (old) post to the Cygwin list which implies that
> /usr/bin/tclsh is usual for UNIX-like operating systems:
> 
>   http://cygwin.com/ml/cygwin/2003-02/msg00007.html

That was specific to cygwin where they kept renaming the tclsh executable
for each version.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 19:10   ` Gary Thomas
@ 2009-01-06 19:44     ` Jonathan Larmour
  2009-01-07  9:44       ` John Dallaway
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Larmour @ 2009-01-06 19:44 UTC (permalink / raw)
  To: Gary Thomas; +Cc: John Dallaway, ecos-devel

Gary Thomas wrote:
> Jonathan Larmour wrote:
>> John Dallaway wrote:
>>> I was looking at support for UNC file paths in the eCos Configuration
>>> Tool today. The convoluted #! magic we use in our Tcl scripts to find a
>>> Cygwin Tcl shell is getting in the way when calling (eg) heapgen.tcl via
>>> a UNC repository path. This code is only needed to support installations
>>> of Cygwin that are more than 5 years old.
>>>
>>> Rather than increase the complexity of the #! magic still further, I
>>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
>>> within our Tcl scripts. However, this would break compatibility with old
>>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
>>>
>>> Any objections?
>> Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
>> bits being dropped, but I'd still want it to be found from the PATH by some
>> means.
> 
> Does CygWin have '/usr/bin/env'?  This is the "modern" way
> to handle this:
> 
>  #! /usr/bin/env tclsh
>  ...

I'd forgotten about that because I'm a bit wary of it in general as you
can't pass arguments to it, e.g. this doesn't work as you'd expect:
#! /usr/bin/env echo "$@"

But that problem probably doesn't apply to most if not all our cases - the
arguments are passed as-is, so yes this should probably work.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 18:02 #! magic for finding Cygwin Tcl shell John Dallaway
  2009-01-06 18:51 ` Jonathan Larmour
@ 2009-01-06 20:01 ` Bart Veer
  2009-01-07 11:10 ` Tarmo Kuuse
  2 siblings, 0 replies; 13+ messages in thread
From: Bart Veer @ 2009-01-06 20:01 UTC (permalink / raw)
  To: John Dallaway; +Cc: ecos-devel

>>>>> "John" == John Dallaway <john@dallaway.org.uk> writes:

    John> I was looking at support for UNC file paths in the eCos
    John> Configuration Tool today. The convoluted #! magic we use in
    John> our Tcl scripts to find a Cygwin Tcl shell is getting in the
    John> way when calling (eg) heapgen.tcl via a UNC repository path.
    John> This code is only needed to support installations of Cygwin
    John> that are more than 5 years old.

    John> Rather than increase the complexity of the #! magic still
    John> further, I think it now makes sense to revert to a simple
    John> "#! /usr/bin/tclsh" within our Tcl scripts. However, this
    John> would break compatibility with old Cygwin installations
    John> providing only tclsh8*.exe or cygtclsh80.exe.

    John> Any objections?

There is another approach we could consider. Instead of invoking
"tclsh", we could invoke "ecosconfig tclsh". That would require a
minor change to ecosconfig. Combine that with a statically linked
build of ecosconfig, and we should end up with something much more
robust than the current approach of depending on whatever version of
Tcl happens to be installed, somewhere, under some name or other.

However, any changes along those lines should probably wait until
after the 3.0 release. AFAIK, what we have right now seems to work
well enough.

Bart

-- 
Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 19:37     ` Jonathan Larmour
@ 2009-01-06 20:04       ` Sergei Gavrikov
  0 siblings, 0 replies; 13+ messages in thread
From: Sergei Gavrikov @ 2009-01-06 20:04 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: John Dallaway, ecos-devel

Jonathan Larmour wrote:
> John Dallaway wrote:
> > Hi Jifl
> > 
> > Jonathan Larmour wrote:
> > 
> >>> Rather than increase the complexity of the #! magic still further, I
> >>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
> >>> within our Tcl scripts. However, this would break compatibility with old
> >>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
> >>>
> >>> Any objections?
> >> Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
> >> bits being dropped, but I'd still want it to be found from the PATH by some
> >> means.
> > 
> > Have you ever encountered a Linux system where tclsh is not accessible
> > at /usr/bin/tclsh? Or were you thinking of portability to other
> > operating systems?
> 
> Portability (or a linux system where tclsh was not installed by the system
> owner - not everyone's environment is their own desktop). Command line
> stuff needs to work more widely than Linux. tclsh in /usr/local/bin or the
> user's home dir or ...
> 
> > I note your (old) post to the Cygwin list which implies that
> > /usr/bin/tclsh is usual for UNIX-like operating systems:
> > 
> >   http://cygwin.com/ml/cygwin/2003-02/msg00007.html
> 
> That was specific to cygwin where they kept renaming the tclsh executable
> for each version.

Hi

Richard Suchenwirth found that sha-bang

#!/usr/bin/env tclsh

also works (starts the first tclsh in PATH) quite nicely on his Linux,
Solaris, and Cygwin installations - so he will use this instead of exec
magic in the future.

http://wiki.tcl.tk/812 ;# [exec magic]

Sergei


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 19:44     ` Jonathan Larmour
@ 2009-01-07  9:44       ` John Dallaway
  2009-01-07 13:39         ` Jonathan Larmour
  0 siblings, 1 reply; 13+ messages in thread
From: John Dallaway @ 2009-01-07  9:44 UTC (permalink / raw)
  To: Jonathan Larmour, Gary Thomas; +Cc: ecos-devel

Jonathan Larmour wrote:

> Gary Thomas wrote:
>> Jonathan Larmour wrote:
>>> John Dallaway wrote:
>>>> Rather than increase the complexity of the #! magic still further, I
>>>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
>>>> within our Tcl scripts. However, this would break compatibility with old
>>>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
>>>>
>>>> Any objections?
>>> Yes, it may not be in /usr/bin. I don't mind the cygwin-specific cygpath
>>> bits being dropped, but I'd still want it to be found from the PATH by some
>>> means.
>> Does CygWin have '/usr/bin/env'?  This is the "modern" way
>> to handle this:
>>
>>  #! /usr/bin/env tclsh
>>  ...
> 
> I'd forgotten about that because I'm a bit wary of it in general as you
> can't pass arguments to it, e.g. this doesn't work as you'd expect:
> #! /usr/bin/env echo "$@"
> 
> But that problem probably doesn't apply to most if not all our cases - the
> arguments are passed as-is, so yes this should probably work.

"#! /usr/bin/env tclsh" will work for modern Cygwin, but are we able to
guarantee the availability and location of "env" any more than that of
"tclsh" for some arbitrary UNIX-like OS?

There has been no objection to dropping support for tclsh83 and
cygtclsh80 so, for the time being, I will take the robust and minimally
invasive approach of tweaking the CDL make rule to call "tclsh
heapgen.tcl ..." directly. Clearly we don't need the convenience of #!
magic in this particular context.

John Dallaway

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-06 18:02 #! magic for finding Cygwin Tcl shell John Dallaway
  2009-01-06 18:51 ` Jonathan Larmour
  2009-01-06 20:01 ` Bart Veer
@ 2009-01-07 11:10 ` Tarmo Kuuse
  2009-01-07 11:53   ` Gary Thomas
  2 siblings, 1 reply; 13+ messages in thread
From: Tarmo Kuuse @ 2009-01-07 11:10 UTC (permalink / raw)
  To: ecos-devel

John Dallaway wrote:
> Rather than increase the complexity of the #! magic still further, I
> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
> within our Tcl scripts. However, this would break compatibility with old
> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.

Source distribution using automake installs stuff to "/usr/local" by 
default. When a user has installed tcl from source (which probably 
happens every now and then), their executable is "/usr/local/bin/tclsh".

The "env" utility, on the other hand, is almost never installed to any 
other location than "/usr/bin/env" because it comes with the base system.

--
Kind regards,
Tarmo Kuuse

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-07 11:10 ` Tarmo Kuuse
@ 2009-01-07 11:53   ` Gary Thomas
  0 siblings, 0 replies; 13+ messages in thread
From: Gary Thomas @ 2009-01-07 11:53 UTC (permalink / raw)
  To: Tarmo Kuuse; +Cc: ecos-devel

Tarmo Kuuse wrote:
> John Dallaway wrote:
>> Rather than increase the complexity of the #! magic still further, I
>> think it now makes sense to revert to a simple "#! /usr/bin/tclsh"
>> within our Tcl scripts. However, this would break compatibility with old
>> Cygwin installations providing only tclsh8*.exe or cygtclsh80.exe.
> 
> Source distribution using automake installs stuff to "/usr/local" by
> default. When a user has installed tcl from source (which probably
> happens every now and then), their executable is "/usr/local/bin/tclsh".
> 
> The "env" utility, on the other hand, is almost never installed to any
> other location than "/usr/bin/env" because it comes with the base system.

I agree - this is about as fixed as possible.  If 'env' were ever
installed anywhere other than "/usr/bin", much would come to a halt.

I [personally] think this is the best solution as it automatically
honors the user's $PATH

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-07  9:44       ` John Dallaway
@ 2009-01-07 13:39         ` Jonathan Larmour
  2009-01-07 17:06           ` John Dallaway
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Larmour @ 2009-01-07 13:39 UTC (permalink / raw)
  To: John Dallaway; +Cc: ecos-devel

John Dallaway wrote:
> 
> "#! /usr/bin/env tclsh" will work for modern Cygwin, but are we able to
> guarantee the availability and location of "env" any more than that of
> "tclsh" for some arbitrary UNIX-like OS?

'env' is a utility defined by POSIX, whereas 'tclsh' isn't.

> There has been no objection to dropping support for tclsh83 and
> cygtclsh80 so, for the time being, I will take the robust and minimally
> invasive approach of tweaking the CDL make rule to call "tclsh
> heapgen.tcl ..." directly. Clearly we don't need the convenience of #!
> magic in this particular context.

We may as well have an identical solution for all scripts, including those 
that do want to be invoked directly on the command line.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["The best things in life aren't things."]------      Opinions==mine

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: #! magic for finding Cygwin Tcl shell
  2009-01-07 13:39         ` Jonathan Larmour
@ 2009-01-07 17:06           ` John Dallaway
  0 siblings, 0 replies; 13+ messages in thread
From: John Dallaway @ 2009-01-07 17:06 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: ecos-devel

Jonathan Larmour wrote:

> John Dallaway wrote:
>>
>> "#! /usr/bin/env tclsh" will work for modern Cygwin, but are we able to
>> guarantee the availability and location of "env" any more than that of
>> "tclsh" for some arbitrary UNIX-like OS?
> 
> 'env' is a utility defined by POSIX, whereas 'tclsh' isn't.
> 
>> There has been no objection to dropping support for tclsh83 and
>> cygtclsh80 so, for the time being, I will take the robust and minimally
>> invasive approach of tweaking the CDL make rule to call "tclsh
>> heapgen.tcl ..." directly. Clearly we don't need the convenience of #!
>> magic in this particular context.
> 
> We may as well have an identical solution for all scripts, including
> those that do want to be invoked directly on the command line.

OK. There are 9 occurrences:

  devs/framebuf/synth/current/src/gen_synthfb.tcl
  ecosadmin.tcl
  fs/rom/current/support/file2c.tcl
  hal/mips/ref4955/current/misc/swap4.tcl
  hal/mips/ref4955/current/misc/slow_cat.tcl
  hal/arm/e7t/current/src/flash_cksum.tcl
  hal/arm/aeb/current/src/flash_cksum.tcl
  io/framebuf/current/src/gen_framebufs.tcl
  pkgconf/fixhtml.tcl
  services/memalloc/common/current/src/heapgen.tcl

I will clean these up to use "#! /usr/bin/env tclsh".

John Dallaway

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-01-07 17:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-06 18:02 #! magic for finding Cygwin Tcl shell John Dallaway
2009-01-06 18:51 ` Jonathan Larmour
2009-01-06 19:10   ` Gary Thomas
2009-01-06 19:44     ` Jonathan Larmour
2009-01-07  9:44       ` John Dallaway
2009-01-07 13:39         ` Jonathan Larmour
2009-01-07 17:06           ` John Dallaway
2009-01-06 19:13   ` John Dallaway
2009-01-06 19:37     ` Jonathan Larmour
2009-01-06 20:04       ` Sergei Gavrikov
2009-01-06 20:01 ` Bart Veer
2009-01-07 11:10 ` Tarmo Kuuse
2009-01-07 11:53   ` Gary Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).