[Geany] vte hazard

Enrico Tröger enrico.troeger at xxxxx
Wed Dec 5 15:19:39 UTC 2007


On Tue, 4 Dec 2007 16:16:34 -0600, "Jeff Pohlmeyer"
<yetanothergeek at gmail.com> wrote:

> I just noticed a little quirk with the "Follow path of current file"
> option for VTE.
> 
> Consider this...
>  1. Open a file in your $HOME directory.
>  2. Open another file from some other directory.
>  3. In vte, type "echo" followed by a space, but don't press return.
>  4. Click the on the tab of the first file you opened.
> 
> The resulting command is "echo cd /home/username"
> 
> Now imagine if you had typed "rm -rf " instead of "echo "
It's getting really funny if the path of the file is "/" ;-).

> Maybe it would be safer to only issue the cd command if there
> is no other text on the command line. I skimmed through the
> vte headers and the only thing I see that might work is to
> call vte_terminal_get_cursor_position() first, and check to
> make sure the column value is zero.
Yes but checking the column to zero doesn't help because it isn't at
all. But we could keep the cursor position after a sent command(e.g.
cd ...) and then compare it to the current cursor position just before
sending any command to the VTE. This works in theory, but while testing
it I noticed another problem:
we send "cd ..." to the VTE using vte_terminal_feed_child() and after
that we retrieve the current cursor position. But we get the "old"
position because vte_terminal_feed_child() works asynchronously and so
the code to retrieve the cursor position is executed before the cd
command was actually executed. And I don't see a way to detect when the
executed command within the VTE has finished.

The only thing I could imagine is to delay the retrieval of the new
cursor position so that we can assume the command has finished. But
this is somewhat ugly and may cause other errors. Delaying the cursor
position retrieval could work for the "cd" command when switching
between tabs but will probably fail when using the Run command in the
VTE.
Attached is a patch to check for changed cursor positions after a delay
of 0.5 seconds. It seems to work for the "cd" command but it breaks the
auto path changing feature as well as the ability to run commands in the
VTE if one runs an open file in the VTE and the duration of the
command is longer than the delay (0.5 seconds). All should work again
after the VTE is restarted.

I'm not sure at all whether the way I did it in the patch is good,
whether we should it in this way or whether there is any better way(I
hope so).

Thanks for reporting, good catch.

Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vte_check_cmd.patch
Type: text/x-diff
Size: 2990 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/users/attachments/20071205/dc1bc532/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/users/attachments/20071205/dc1bc532/attachment.pgp>


More information about the Users mailing list