From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from math.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by werple.net.au (8.7/8.7.1) with SMTP id TAA25968 for ; Thu, 9 Nov 1995 19:35:24 +1100 (EST) Received: by math.gatech.edu (5.x/SMI-SVR4) id AA00679; Thu, 9 Nov 1995 03:17:11 -0500 Resent-Date: Thu, 9 Nov 1995 10:18:42 +0200 Old-Return-Path: Date: Thu, 9 Nov 1995 10:18:42 +0200 From: sverre@research.nokia.com (Sverre Slotte) Message-Id: <9511090818.AA23545@nike.spices> Newsgroups: comp.unix.shell Subject: zsh: read with timeout? Organization: Nokia Research Center Apparently-To: zsh-list@sterling.com Resent-Message-Id: <"GfFk-3.0.UA.6aRem"@euclid> To: zsh-workers@math.gatech.edu Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/582 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Gurus and mere mortals, Is there a way to give the read-command (in zsh) a timeout-value? When I log in to my workstation, I want my login-script to ask me which window manager to run. If I don't answer anything, I want it to run the default manager. My present solution is a kludge: I spawn off a subprocess which sleeps for a while and then sends a signal to the parent process. This signal lets the script break out of the read. Is there a better way? This is the relevant part of my .zlogin file: ------------------------------------------------------- if [[ $TTY = /dev/console && -a /dev/fb ]] then # Choose window manager. If no input within specified period of # time, a default is chosen. "Interesting" hack handles timeout # process. nop() { } # dummy func def trap nop INT # trap ^C ( sleep 15; kill -INT $$ 2>/dev/null ) & disown %% echo -n "Console, Fvwm, Motif, OpenWindows or SunView? " read answer # fvwm is my default window manager, hence "${answer:-f}". case ${answer:-f} in c|C) # this should leave us on the console ;; f|F) export XINITRC=.xinitrc.fvwm openwin -ar1 250 -ar2 25 -nobanner clear logout ;; m|M) export XINITRC=.xinitrc.mwm /usr/bin/X11/mwm clear logout ;; o|O) # kbd-def's in file .SverreKeys.ps export XINITRC=.xinitrc.olwm openwin clear logout ;; s|S) loadkeys ~/.setkbd.swe sunview clear logout ;; *) # should we do something here? ;; esac fi ------------------------------------------------------- Sverre ---------------------------------------------------------------------------- Sverre Slotte Internet: sverre@research.nokia.com Nokia Research Center Phone: + 358 0 43766208 P.O.Box 45, 00211 Helsingfors, Finland Phax: + 358 0 43766856 ---------------------------------------------------------------------------- "Kajakken er uten sammenligning den ypperste enkeltmannsfarkost som finnes." -- Fritjof Nansen 1891