#!/usr/bin/perl -w # # notesinit # Copyright (C) 1996-2002,2012 Free Software Foundation, Inc. # $Id: notesinit,v 1.12 2006/01/14 22:52:56 johnh Exp $ # sub usage { print STDERR <= 0 && $ARGV[0] eq '-?'); my($use_defaults) = defined($opts{'D'}); my($PERL) = $^X; # location of perl executable use POSIX; BEGIN { unshift(@INC, $ENV{'NOTES_BIN_DIR'}); }; use NotesVars; use strict; sub query { my($lc) = 1; if ($_[0] eq '-nolc') { $lc = undef; shift @_; }; my($expl, $query, $valid_regexp, $default) = @_; return $default if ($use_defaults); print $expl; my($a); for (;;) { print $query; $a = <>; chomp $a; $a = lc($a) if ($lc); return $default if ($a eq ''); return $a if ($a =~ /$valid_regexp/); print "I didn't understand your answer `$a'.\n"; }; } my($expl); $expl = <. Everything you will be asked here is discussed in greater detail in the documentation. END my($home_dir) = ((getpwuid($<))[7]); my($def_choices, $def) = ('(Y/n)', 'y'); if (-f "$home_dir/.notesrc") { die "$0: will not override existing .notesrc with -D option.\n" if ($use_defaults); ($def_choices, $def) = ('(y/N)', 'n'); print "WARNING: you already appear to have notes configured.\n\n" }; my($a) = query($expl, "Do you want to set up notes mode now $def_choices? ", '(y|n)', $def); if ($a ne 'y') { print "\nnotesinit exited.\n\n"; exit 1; }; $expl = <$home_dir/.notesrc <$today_pathname <>$tmpfile; echo '$crontab_entry' >>$tmpfile; " . $::notes{bin_dir} . "/setcrontab $tmpfile rm -f $tmpfile"); print "\n### changes end here\n" if (!$use_defaults); print "\nYou have elected to have the changes DESCRIBED but not made.\n" . "To make the changes yourself, run the commands between\n" . "\"changes begin here\" and \"changes end here\".\n" if ($go eq 'd'); exit 0;