Question

I want to run steam on linux, and I don't want to install xterm, there are two moments when does it want xterm

echo -e "$*" >$tmpfile
xterm -T "$title" -e "cat $tmpfile; echo -n 'Press enter to continue: '; read input"
rm -f $tmpfile 

and

# Fall back to sudo in a terminal
xterm -e sudo -p "$prompt
[sudo] password for user: " $*

is it safe for posix to use ${TERM} instead of xterm here?

Was it helpful?

Solution

Assuming the script will be running in an X session; no, there is no reason to believe that TERM will be set under those circumstances (and if it is, it would be a coincidence for it to point to a binary of the same name -- the contents of this variable should be a key for Termcap or Terminfo; a lot of the time, on modern systems, it might be something like vt220 if it's not some variant of xterm, or emacs or dumb).

On the other hand, if your environment is X, you are basically guaranteed to have xterm.

Debian defines x-terminal-program (IIRC) to let the user or system administrator pick a different default terminal emulator.

I don't think POSIX 1003 has any concept of the problem you are attempting to solve (and we are guessing, too; perhaps you could add more details to your question?)

A better platform to require users to have available might be Freedesktop.org but I have no idea whether e.g. Mac OSX adheres to any useful subset of that. (They might implement all if it; I simply don't know.)

On the other hand, the simple, crude fix would be to require the script to be run from a terminal in the first place; then, you can simply use cat to display text files (your EULA, I would guess?) and echo (or cat again) and read to interact with the user. That is, don't attempt to open a new terminal window for these things. Maybe do all interaction near the beginning of the script to make it easy to bail out early.

If you want graphical interaction, you need to limit your target platform, or write complex wrapping for each different environment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top