Using:shopt -q login_shell && echo Login = yes || echo Login = noAnswers correctly when run in Yakuake, Xterm and other X based terminals that it is not a login shell. In a linux term (ctrl + alt + F1) it answers correctly that it is being run in a login shell.I change the code to:shopt -q login_shell && LOGIN=yes || LOGIN=noecho Login = $LOGINNow the 'echoed' answer is always Login = no no matter what terminal thescript is run in. In the linux terminal or X terminals the answer is no.For linux terminals it should be yes. I need to know if the script is run in X or linux. If in X or an X terminal I can use yad for dialogs. Under linux I want to use dialog for my dialogs. I can not seem to get dialog to handle selecting a directories properly, but have found a work around to create menus purely in bash scripting.$TERM tells me linux under a linux terminal and xterm under Yakuake and other some xterm based terminals. I am how ever timid to use it because I am afraid I may run into terminals that I won't get a response my script will recognize since I do not know all the possible responses I could get from $TERM. I have also tried:[ -t ]and$-They do not seem reliable $- should return something like himBH but in some terminals I do not get the i in the himBH. This i flag means interactive and is suppose to refer to a terminal as a terminal is an interactive interface.I need to determine whether I am in a terminal, and whether the terminal is a linux or X. The script either needs to know if it is run in linux or X, or from X or a terminal. If I can tell if it is run in linux or X, I can run a X based GUI on that and always use a GUI even when run in a terminal, and only switch to terminal based menus under linux. The alternative is to switch to terminal based menus anytime a terminal is used.tty -scase $? in    0) TERMINAL=1    1) TERMINAL=0esacecho $TERMINALreturns a 1 for terminal and 0 for non terminal use. Note I could have just said: TERMINAL=$?If I had then 0 is for terminal and 1 for non terminal use. I thought that was counter intuitive though. Also I check can check for the existence of yad which is my preferred manner of displaying a GUI for X.So now that I have explained. Does anyone have a bash only way to detect terminals and whether a script is run in X?
shopt -q login_shell && echo Login = yes || Login = no problems
linux;terminal;x11;shopt