lundi 23 mars 2015

Can a command in a shell pipeline determine the tty characteristics of its context?


I have a bash script that columnizes a list of items. By default it will guess at the number of columns to output, based on the terminal width as reported by stty size. But when the script is in a pipeline, stty reports "Inappropriate ioctl for device".


What I want is to allow my script, when being executed as a command in the middle of a pipeline, to discover whether the pipeline it's part of is ultimately outputting to a tty - and if so, be able to stty its characteristics.



Aucun commentaire:

Enregistrer un commentaire