Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion read -t und read -n1 in POSIX
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martin Vaeth  
View profile   Translate to Translated (View Original)
 More options Feb 10 2009, 3:31 am
Newsgroups: de.comp.os.unix.shell
From: Martin Vaeth <va...@mathematik.uni-wuerzburg.de>
Date: Tue, 10 Feb 2009 08:31:18 +0000 (UTC)
Local: Tues, Feb 10 2009 3:31 am
Subject: read -t und read -n1 in POSIX
Hallo,

bei der Konvertierung eines bash-Skripts in POSIX bin ich auf ein
Problem gestossen, fuer das ich keine Skript-Loesung finde:
Bashs read kennt -t (timeout) und -n1 (Ende nach 1 Zeichen),
POSIX aber nicht.
Gibt es in POSIX eine Moeglichkeit zu testen, ob ein Zeichen an stdin
anliegt und/oder dieses zu holen?
Die Alternative fuer -t waere wohl, read asyncron zu starten (um die
Prozess-ID zu bekommen), dann einen Prozess zu starten, der dieses
nach gewisser Zeit killt, und dann read wieder nach vorne zu holen.
Aber dabei ist mir erstens nicht klar, ob dabei garantiert ist, dass read
den urspruenglichen Input wiederbekommt (obwohl das bei dash zumindest so
zu sein scheint), und zweitens weiss ich nicht, wie ich wieder an den
stdout eines "nach vorne geholten" Prozesses komme: A=$(fg) geht nicht,
weil in der Subshell ja kein Prozess gestartet wurde.
Ausser Ausgabe in temporaere Files/FiFos, die fuer eine Tastaturabfrage
aber wirklich unangebracht sind und die ich aus anderen Gruenden ohnehin
vermeiden muss, faellt mir nichts ein.
Kann man in POSIX' Shell wirklich kein read -t emulieren?
Mit read -n1 sieht es wohl noch viel schlimmer aus...

Schoene Gruesse
Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.