Tuesday, 7 July 2020

Fix No value for $TERM and no -T specified

What ultimately worked for me was to check whether the shell was an interactive shell. I based the solution on this other post at unix.stackexchange: How to check if a shell is login/interactive/batch.

So the code for the solution was:

if [[ $- == *i* ]]; then
  fgRed=$(tput setaf 1)     ; fgGreen=$(tput setaf 2)  ; fgBlue=$(tput setaf 4)
  fgMagenta=$(tput setaf 5) ; fgYellow=$(tput setaf 3) ; fgCyan=$(tput setaf 6)
  fgWhite=$(tput setaf 7)   ; fgBlack=$(tput setaf 0)
  bgRed=$(tput setab 1)     ; bgGreen=$(tput setab 2)  ; bgBlue=$(tput setab 4)
  bgMagenta=$(tput setab 5) ; bgYellow=$(tput setab 3) ; bgCyan=$(tput setab 6)
  bgWhite=$(tput setab 7)   ; bgBlack=$(tput setab 0)
fi

No comments:

Post a Comment

How to check if a file contains a specific string using Bash

 In case if you want to check whether file does not contain a specific string, you can do it as follows. if ! grep -q SomeString "$File...