Re: Executing files

From: vais <vsalik....at.gmail.com>
Date: Sun, 15 Feb 2009 10:29:18 -0800 (PST)

The issue is here: http://code.google.com/p/textadept/issues/detail?id=61

I added the requirement to preserve current working dir before
changing it, then restore it back, just in case - there should not be
any side-effects left over after running the command, and changing the
working directory is surely a side-effect that can bite one on the ass
later, when one least expects it :)

Vais

On Feb 15, 12:55 pm, vais <vsalik....at.gmail.com> wrote:
> Alex,
>
> > 2. On Windows, an ugly console window pops up when a file is run. Is
> > there any way to avoid this?
>
> The ugly console window pops up on Win32 any time Lua's os.execute or
> io.popen is used. This has always been a problem in Win32 Lua. I ran
> into this way back when using these functions from Scite.  There is no
> work-around for this other than not using these Lua facilities under
> Win32 and implementing a platform-specific Win32 solution (which is
> what Scite does). You can read more about it here:http://groups.google.com/group/scite-interest/browse_thread/thread/78...
>
> Mitchell,
>
> > Howso? Do you have an example?
>
> It is very simple. If the file you run depends/makes references to/
> uses/produces other files relative to or inside the same directory as
> itself, current implementation of go() is trouble. Here is a simple
> example that fails because the "my todo for textadept.txt" file is on
> my desktop next to this Ruby script I am running:
>
> puts File.read("my todo for textadept.txt")
>
> The result is:
>
> > ruby  "/Users/vais/Desktop/test.rb" 2>&1
>
> /Users/vais/Desktop/test.rb:1:in `read': No such file or directory -
> my todo for textadept.txt (Errno::ENOENT)
>         from /Users/vais/Desktop/test.rb:1
>
> Just one line needs to be added to go() as shown below to fix this
> problem:
>
> function go()
>   if not buffer.filename then return end
>   local ext = buffer.filename:match('[^.]+$')
>   local action = go_for_ext[ext]
>   if not action then return end
>   local f, args = action[1], { unpack(action) }
>   table.remove(args, 1) -- function
> -- vais--
> lfs.chdir("/Users/vais/Desktop");
> -- siav --
>   f(unpack(args))
> end
>
> Obviously, the path should not be hard-coded to my Desktop, but
> calculated from the file being run :)
>
> I will create an issue for this in the issue tracking system.
>
> Thanks,
>
> Vais
>
> On Feb 15, 12:10 am, mitchell <mforal.n....at.gmail.com> wrote:
>
> > Hi Alex,
>
> > > 1. What do you thing about changing the working directory to the
> > > directory of the file being run? Otherwise the results of the
> > > execution may be confusing as they differ from what one gets when one
> > > runs the file on the console in the directory that contains the file.
>
> > Howso? Do you have an example?
>
> > > 2. On Windows, an ugly console window pops up when a file is run. Is
> > > there any way to avoid this?
>
> > Not that I know of.
>
> > > 3. TA is blocked while the started process is still active. How about
> > > having the execution in a separate thread?
>
> > I do not know how to do this, but that might be a good idea.
>
Received on Sun 15 Feb 2009 - 13:29:18 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:37:23 EST