Thanks, keefaz. Bugs happen all the time! I now see I made a lot of work without giving proper thinking to the overall process. I intended to decide whether to invoke vim with or without TERM=linux-m with the final if in the script:
Code:
if [ $? -eq 0 ]
then
## TERM=linux-m, call vim, restaure TERM
else
## Xnotrunning, call vim.
fi
exit
Wrong! I should ask FROM WHERE I am invoking vim, if from a vc (virtual console) or from /usr/bin/Terminal, which is an X application. But it was an exercise after all.