zsh-workers
 help / color / mirror / code / Atom feed
* Re: zsh: read with timeout?
@ 1995-11-12  0:05 Karl E. Vogel
  0 siblings, 0 replies; 3+ messages in thread
From: Karl E. Vogel @ 1995-11-12  0:05 UTC (permalink / raw)
  To: acs; +Cc: sverre, zsh-workers

>> On Thu, 09 Nov 1995 08:37:57 -0500, 
>> acs@world.std.com said:

      [Is there a way to give the read-command (in zsh) a timeout-value?]

V> I don't know of any way to get zsh to do this.  I would get expect from
V> ftp.cme.nist.gov:/pub/expect.  It's really designed to handle timeouts
V> and make decisions based on returned values, and..... all kinds of neat
V> stuff.

   Check out "grabchars" in comp.sources.misc volume 12.  It's intended for
   use in shell scripts where you might want a timeout, default answer, or
   restricted set of allowed answers for a given prompt.

-- 
Karl Vogel                                        vogelke@c17mis.wpafb.af.mil
Control Data Systems, Inc.           ASC/YCOA, Wright-Patterson AFB, OH 45433


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zsh: read with timeout?
  1995-11-09  8:18 Sverre Slotte
@ 1995-11-09 13:37 ` Vinnie Shelton
  0 siblings, 0 replies; 3+ messages in thread
From: Vinnie Shelton @ 1995-11-09 13:37 UTC (permalink / raw)
  To: Sverre Slotte; +Cc: zsh-workers

In message <9511090818.AA23545@nike.spices>, Sverre Slotte wrote:
>Is there a way to give the read-command (in zsh) a timeout-value? 

I don't know of any way to get zsh to do this.
I would get expect from ftp.cme.nist.gov:/pub/expect.
It's really designed to handle timeouts and make decisions
based on returned values, and..... all kinds of neat stuff.

--vin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* zsh: read with timeout?
@ 1995-11-09  8:18 Sverre Slotte
  1995-11-09 13:37 ` Vinnie Shelton
  0 siblings, 1 reply; 3+ messages in thread
From: Sverre Slotte @ 1995-11-09  8:18 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-11-12  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-12  0:05 zsh: read with timeout? Karl E. Vogel
  -- strict thread matches above, loose matches on Subject: below --
1995-11-09  8:18 Sverre Slotte
1995-11-09 13:37 ` Vinnie Shelton

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).