I have a debug trap that runs every time I enter a command in bash that sets the window title to indicate what command is running. I'm leaving out all the configuration details and boil it down to:
export PS1="\[\e]0;$GENERATED_WINDOW_TITLE\a\]$GENERATED_PROMPT"
This works incredibly well, with only one snag: if the bash shell is running in an environment that does not support this feature, the GENERATED_WINDOW_TITLE is printed on the screen with each prompt. This happens any time I'm running bash from a non-X terminal.
How can bash tell if this escape sequence is supported?