Re: Debugging gvim :!cmd with bash

From: Fred Ma (fma_at_doe.carleton.ca)
Date: 04/03/04


Date: 3 Apr 2004 05:09:03 GMT

Gary Johnson wrote:
>
> I seem to recall that later versions of ksh
> included an optimization where they would execute the last command
> of a script as though it had been written "exec command" instead of
> just "command". This would save a fork step and would replace the
> running ksh with the command in the same process rather than
> creating a new process. If that's true for bash, then in the cases
> where your script fails, xterm is replacing the bash that was
> executing the script and it become the child of gvim. In the cases
> where your script works, xterm is the child of bash.

Hi, Gary,

Thanks for confirming that my troubleshooting is sane. I understand
your description about the last line in the script getting special
treatment, but I ruled that out by arranging xterm as not the last
command e.g. by adding sanity-checking echo commands to show DISPLAY
or "type xterm". Here are some test cases. They seem to indicate
returning from vim actually kills off the process that is launching
xterm.

              #1: Doesn't work
              ----------------
   BashScript:
      #!/bin/bash
      xterm &
      echo Hello world.

The xterm fails, the echo works. Problem not related to special
treatment of last line.

              #2: Does work
              ----------------
   BashScript:
      #!/bin/bash
      xterm &
      sleep 1
      #######

Somehow, succesful launch of xterm depends on delayed return to vim.

Since my actual situation consists of shelling out to invoke a
wrapper script which itself also invokes another script, I tried the
following.

              #3: Doesn't work
              ----------------
   BashScript: BashScript2:
      #!/bin/bash #!/bin/bash
      BashScript2 & xterm &

This example doesn't say much in itself, since things are happening
too close together in time to know what is happening before what.
Probably returning to vim before xterm has time to launch, thus
triggering the mysterious problem that kills the launch.

              #4: Doesn't work
              ----------------
   BashScript: BashScript2:
      #!/bin/bash #!/bin/bash
      BashScript2 & xterm &
                           sleep 1
                           #######

Again, this doesn't say much because xterm is being launched at around
the same time as the return of control to vim.

              #5: Does work
              ----------------
   BashScript: BashScript2:
      #!/bin/bash #!/bin/bash
      BashScript2 & xterm &
      sleep 1
      #######

As in #2, returning of control to vim is delayed until well after
xterm is launched, which allows the launch to be successful. The
xterm is not terminated when control is returned to vim.

Before, I thought it was a bash problem, now it looks like a vim
shell-out problem. Thanks for any comments, or even sanity checks on
the trivial tests above. I'm running on sparc solaris 8.

Fred

-- 
Fred Ma
Dept. of Electronics, Carleton University
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6


Relevant Pages

  • Re: window manager not picking up Xresources?
    ... window manager are clearly ignoring my Xresources settings. ... If I launch a second window ... So if you define resources for "XTerm" ... The suspect behaviour is exhibited even if the command name is the ...
    (Debian-User)
  • Re: window manager not picking up Xresources?
    ... window manager are clearly ignoring my Xresources settings. ... If I launch a second window ... So if you define resources for "XTerm" ... The suspect behaviour is exhibited even if the command name is the ...
    (Debian-User)
  • Re: window manager not picking up Xresources?
    ... window manager are clearly ignoring my Xresources settings. ... If I launch a second window ... capitals), but you start the program as "xterm," it won't work. ... The suspect behaviour is exhibited even if the command name is the same: ...
    (Debian-User)
  • Re: window manager not picking up Xresources?
    ... window manager are clearly ignoring my Xresources settings. ... If I launch a second window ... capitals), but you start the program as "xterm," it won't work. ... The suspect behaviour is exhibited even if the command name is the same: ...
    (Debian-User)
  • Re: opening vim in a separate window
    ... command for quitting vim, ... well as close the xterm. ...
    (comp.os.linux.misc)