How does my shell script determine if it is in a real shell or not?

I have a shell script that works in my personal terminal and in the CI environment. In CI, python requires the determination of adjacent values ​​for the height and width of the shell.

I would like to do something in mind:

if (I am running in shell context) determine height/width of terminal else don't fi 

How can I express this condition in a bash script?

+4
source share
1 answer

Check if the standard input is a tty device.

In sh / bash:

 if [ -t 0 ]; then 

In Python:

 if os.isatty(sys.stdin): 
+6
source

Source: https://habr.com/ru/post/1345690/


All Articles