<p dir="ltr">Ok, Let me understand it. So the keyboard interrupted exception is coming from prompt.py, not from grass.py. If I replace prompt.py with prompt.sh, I'm out of python completely and not facing performance hit either?</p>
<p dir="ltr">I thought as long as grass.py launches bash with whatever PROMPT_COMMAND either being prompt.py or prompt.sh, I'm inside a python process and cannot avoid keyboard interuption exceptions and slow performance.</p>
<p dir="ltr">Huidae</p>
<div class="gmail_quote">On May 12, 2014 6:37 PM, "Glynn Clements" <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Huidae Cho wrote:<br>
<br>
> Would I miss any functionalities by using prompt.sh?<br>
<br>
No.<br>
<br>
> I mean other than portability between OSs,<br>
<br>
prompt.py doesn't provide that. The only way in which the script is<br>
executed is by setting the bash variable PROMPT_COMMAND. If set, bash<br>
treats its value as a command to execute prior to displaying the<br>
primary prompt ($PS1).<br>
<br>
If you're using bash, you can use either prompt.sh or prompt.py (or<br>
something of your own devising, or nothing). If you aren't using bash,<br>
neither of those scripts are of any use to you.<br>
<br>
> does prompt.py provide other benefits? If there's<br>
> nothing to lose in Unix by falling back to prompt.sh, I'd like to bring it<br>
> into 7 and let the user choose. Maybe if the user is in Unix, there is no<br>
> reason at all to use prompt.py?<br>
<br>
I'm not sure that we need a choice. Actually, I'm not sure that we<br>
even need a separate script (in any language). $PROMPT_COMMAND can be<br>
any bash command; it doesn't have to be an external program. We could<br>
just insert the appropriate code as a bash function into the custom<br>
<mapset>/.bashrc file generated by the startup script.<br>
<br>
IOW, in lib/init/grass.py, replace<br>
<br>
f.write("PROMPT_COMMAND=\"'%s'\"\n" % os.path.join(gisbase, 'etc',<br>
'prompt.py'))<br>
<br>
with<br>
<br>
f.write("""<br>
grass_prompt () {<br>
LOCATION="`g.gisenv GISDBASE`/`g.gisenv LOCATION_NAME`/`g.gisenv MAPSET`"<br>
if test -d "$LOCATION/grid3/G3D_MASK" && test -f "$LOCATION/cell/MASK" ; then<br>
echo [Raster and Volume MASKs present]<br>
elif test -f "$LOCATION/cell/MASK" ; then<br>
echo [Raster MASK present]<br>
elif test -d "$LOCATION/grid3/G3D_MASK" ; then<br>
echo [Volume MASK present]<br>
fi<br>
}<br>
PROMPT_COMMAND=grass_prompt<br>
""")<br>
<br>
--<br>
Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>><br>
</blockquote></div>