<br><br><div class="gmail_quote">On Tue, Apr 15, 2008 at 4:17 PM, Cameron Simpson <<a href="mailto:cs@zip.com.au">cs@zip.com.au</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On 15Apr2008 12:09, Don Russell <<a href="mailto:fedora@drussell.dnsalias.com">fedora@drussell.dnsalias.com</a>> wrote:<br>
| On Tue, Apr 15, 2008 at 11:08 AM, Patrick O'Callaghan <<a href="mailto:pocallaghan@gmail.com">pocallaghan@gmail.com</a>><br>
| wrote:<br>
| > On Tue, 2008-04-15 at 10:49 -0700, Don Russell wrote:<br>
| > > How can I tell, from a Korn shell script, if the script is running in<br>
| > > a vi sub-shell?<br>
| > ><br>
| > > I have a script that has a problem when run from a vi subshell, and<br>
| > > I'd like to check for that condition and just issue an error message.<br>
| > > (I know that's not the solution to the problem, but the thing that<br>
| > > fails is being replaced, so this is a temporary "fix")<br>
| ><br>
| > Try:<br>
| > ls -l /proc/`cat /proc/$$/status|grep PPid|cut -f2`/exe<br>
| > and work from there.<br>
|<br>
| That looks promising... thanks :-)<br>
<br>
</div></div>Promising, but will work only on Linux. That may be enough for you, but you<br>
shouldn't forget that it's nonportable.<br>
</blockquote><div><br>I just tried this on a Linux system... it makes sense... I tried it on a UNIX (AIX) system, and it did not help directly. On UNIX the status file appears to be "raw" binary data that maps to a C structure... could get tricky trying to extract the correct parts.<br>
<br>On Linux, it looks like that decoding is all done and present in human-readable terms. :-)<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
You can probably make that `cat|grep|cut` into a single `sed` at some<br>
performance benefit.<br>
<br>
Another approach is to alter your shell environment to always set and export<br>
an environment variable when starting vi (by invoking vi via a wrapper script<br>
or alias or shell function) and then just checking for it.<br>
</blockquote><div><br>Though simple, that's not an option for me.... I can't "wrap" vi...<br></div></div><br>