[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Debconf in non-interactive mode



In <[🔎] 20101120223808.GA15502@mea.homelinux.org>, Mats Erik Andersson wrote:
>Question: Is there some mechanism I can use in the postinst
>          script that lets me determine whether the upgrade
>          is being conducted in non-interactive mode?

First, you should *assume* non-interactive mode.

To test for interactivity, you could try opening /dev/tty.[1]  It's not 
perfect, but non-interactive processes should generally detach from their 
controlling terminal leaving them without a valid /dev/tty.  Another option is 
to see if both stderr and stdin are ttys, which is how SUSv2 says a shell 
determines if it is interactive.

If both those tests are true, you can be pretty sure that a user can be 
prompted (on stderr, blah) and you can get a response on stdin.  If neither is 
true, you can be pretty sure user input is not forth-coming.  If only one is 
true you can really be sure one way or the other.  (Assume non-interactive, 
plz.)

[1] On Linux, at least.  I don't know if the kFreeBSD port has /dev/tty.
-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: