Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change alarm.osh to require background invocation

  • Loading branch information...
commit 9daeab809a810fa46932f69d62721c0dcbdfff6f 1 parent 852fce3
@JNeitzel authored
Showing with 19 additions and 14 deletions.
  1. +19 −14 alarm.osh
View
33 alarm.osh
@@ -11,11 +11,13 @@
:
: " Cause the user's terminal to act as an alarm clock by repeatedly "
: " ringing the terminal bell at the specified time until the user "
-: " snoozes it or turns it off. This command file may be invoked "
-: " either as a background process (preferred) or as a foreground "
-: " process according to the needs of the user. "
+: " snoozes it or turns it off. "
:
-: " usage: alarm [CCYYMMDDhhmm | off | snooze] "
+: " usage: ( alarm CCYYMMDDhhmm & ) "
+: " or: "
+: " usage: alarm CCYYMMDDhhmm & "
+: " or: "
+: " usage: alarm [off | snooze] "
:
umask 0077
@@ -39,8 +41,20 @@ expr \
//$1 : \
'//[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*' = \
//$1 : '//.*' \
-} if { exit } pusage $0 '"[CCYYMMDDhhmm | off | snooze]"' >/dev/null
+} goto Usage >/dev/null
+goto Continue
+
+: Usage
+fd2 -e -- head -5 ; false ; exit
+usage: ( alarm CCYYMMDDhhmm & )
+ or:
+usage: alarm CCYYMMDDhhmm &
+ or:
+usage: alarm [off | snooze]
+
+: Continue
if -e alarm if { exit } perror $0 '"Already running."'
+if X$t != X goto Usage
:
: " Set everything up as needed... "
@@ -67,15 +81,6 @@ if ! -e alarm if { exit } perror $0 '"Cannot ring alarm in the past."'
echo "echo "$$" | sed 's,^0*\(.*\),ps -p\1,' | osh - ; :" ; \
) >status
-if X$t = X goto Timer
- :
- : " Allow SIGINT, and inform user how to terminate alarm. "
- : " User should run `alarm off' *after* it terminates... "
- :
- sigign - 2
- perror $0 '"Type an INTR (^C) to terminate alarm process."'
- : fallthrough
-
: Timer
sleep 60 ; date '+%Y%m%d%H%M%S' >timer
if timer -ot alarm goto Timer
Please sign in to comment.
Something went wrong with that request. Please try again.