From c15c8ba73115e6ba72e3c7b6ca282c6159a4b045 Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Fri, 10 Feb 2012 20:29:50 +0100 Subject: [PATCH] FIXED: removed any file/path actions using '/'. replaced by portable functions by using File::Spec. This makes it possible to run note unchanged on win32 (and possibly any other) environments. FIXED: added a whitespace to the prompt in interactive mode to circumvent a bug in the win32 Term::ReadLine module which causes the cursor to be displayed on the left side (column 0) of the screen. FIXED: added "or die" code to some commands which are running inside an eval{} block to fetch errors. Without the "or die"s no error could ever catched. CHANGED: removed HOME variable support of the noterc. in fact, if it exists, no error will occur, but it will no longer be used. It didn't work in older versions anyway. ADDED: It is now possible to quit note using CTRL-D (or: EOF) --- Changelog | 21 ++++++++++++++++++ README | 4 ++-- bin/note | 60 ++++++++++++++++++++++++++++++--------------------- config/noterc | 11 +++------- note.pod | 2 +- 5 files changed, 62 insertions(+), 36 deletions(-) diff --git a/Changelog b/Changelog index 8cf5d3e..9fd60f5 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,24 @@ +================================================================================ +1.2.5: +FIXED: removed any file/path actions using '/'. replaced by portable + functions by using File::Spec. This makes it possible to run + note unchanged on win32 (and possibly any other) environments. + +FIXED: added a whitespace to the prompt in interactive mode to + circumvent a bug in the win32 Term::ReadLine module which causes + the cursor to be displayed on the left side (column 0) of + the screen. + +FIXED: added "or die" code to some commands which are running inside + an eval{} block to fetch errors. Without the "or die"s no + error could ever catched. + +CHANGED: removed HOME variable support of the noterc. in fact, if it + exists, no error will occur, but it will no longer be used. + It didn't work in older versions anyway. + +ADDED: It is now possible to quit note using CTRL-D (or: EOF) + ================================================================================ 1.2.4: CHANGED: in the function find_editor() the alternatives vim and pico diff --git a/README b/README index 5905729..98eb801 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -note 1.2.4 by Thomas Linden, 22/03/2003 +note 1.2.5 by Thomas Linden, 19/01/2004 ======================================= Introduction @@ -205,4 +205,4 @@ and I'll add you. Last changed ============ -22/03/2003 +19/01/2004 \ No newline at end of file diff --git a/bin/note b/bin/note index 07b8ab3..211e224 100755 --- a/bin/note +++ b/bin/note @@ -1,7 +1,7 @@ #!/usr/bin/perl # # note - console notes management with database and encryption support. -# Copyright (C) 1999-2003 Thomas Linden (see README for details!) +# Copyright (C) 1999-2004 Thomas Linden (see README for details!) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -27,6 +27,9 @@ use strict; no strict 'refs'; #use Data::Dumper; use Getopt::Long; +use FileHandle; +use File::Spec; + # # prototypes @@ -112,10 +115,9 @@ $date = &getdate; $USER = getlogin || getpwuid($<); chomp $USER; $HOME = $ENV{'HOME'}; -$CONF = $HOME . "/.noterc"; +$CONF = File::Spec->catfile($HOME, ".noterc"); $dbdriver = "binary"; -$libpath = "/usr/local/lib"; -$NOTEDB = $HOME . "/.notedb"; +$NOTEDB = File::Spec->catfile($HOME, ".notedb"); $MAX_NOTE = 4096; $MAX_TIME = 84; $COLOR = "YES"; @@ -126,12 +128,12 @@ $TIME_COLOR = "blue"; $TOPIC_COLOR = "bold"; $TOPIC = 1; $TopicSep = '/'; -$version = "1.2.4"; +$version = "1.2.5"; if ($TOPIC) { $CurDepth = 1; # the current depth inside the topic "directory" structure... } $USE_CRYPT = "NO"; -$TempDir = "/tmp"; +$TempDir = File::Spec->tmpdir(); # mysql stuff $table = "note"; $fnote = "note"; @@ -370,7 +372,9 @@ if ($DEFAULT_LIST eq "LONG") { # *if* loading of the config was successful, try to load the # configured database backend. Currently supported: # mysql, dbm and binary. -unshift @INC, $libpath; +if ($libpath) { + unshift @INC, $libpath; +} if ($dbdriver eq "binary") { eval { @@ -381,13 +385,13 @@ if ($dbdriver eq "binary") { elsif ($dbdriver eq "mysql") { # do the new() later because of the encrypted password! eval { - require "NOTEDB/mysql.pm"; + require NOTEDB::mysql; }; die "mysql backend unsupported: $@\n" if($@); } else { eval { - require "NOTEDB/$dbdriver.pm"; + require "NOTEDB::$dbdriver"; $db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate); }; } @@ -423,11 +427,11 @@ if ($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) { eval { local($|) = 1; local(*TTY); - open(TTY,"/dev/tty"); - system ("stty -echo ); print STDERR "\r\n"; - system ("stty echo ); print STDERR "\r\n"; - system ("stty echo 2) { - print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . "> "; + print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">"; } else { - print C $menu . $TOPICC . $CurTopic . $_TOPICC . "> "; + print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; } # endless until user press "Q" or "q"! if ($term) { - $char = $term->readline(""); - $term->addhistory($char) if $char =~ /\S/; - $char =~ s/\s*$//; # remove trailing whitespace (could come from auto-completion) + if (defined ($char = $term->readline(" "))) { + $term->addhistory($char) if $char =~ /\S/; + $char =~ s/\s*$//; # remove trailing whitespace (could come from auto-completion) + } + else { + # shutdown + $| = $Channel; + print "\n\ngood bye!\n"; + exit(0); + } } else { $char = ; @@ -1606,13 +1617,12 @@ sub getconfig { $time_format = $value if (/^TimeFormat/); $AUTO_CLEAR = $value if (/^AutoClear/); } - chomp $home; - $home =~ s/\/*$//; # cut eventually / at the end - $HOME = eval($home); + if ($NOTEDB =~ /^(~\/)(.*)$/) { - $NOTEDB = "/home/" . $USER . "/" . $2; + $NOTEDB = File::Spec->catfile($HOME, $2); } - $libpath =~ s/\/*$//; + + $libpath = (File::Spec->splitpath($libpath))[1]; close CONFIG; } diff --git a/config/noterc b/config/noterc index f86499e..31492ba 100644 --- a/config/noterc +++ b/config/noterc @@ -1,10 +1,10 @@ -# 1.2.4 -*- sh -*- +# 1.2.5 -*- sh -*- # This is a sample config for the note script # There are useful defaults set in note itself. # # Copy it to your $HOME as .noterc # -# note is Copyright (c) 1999-2003 Thomas Linden. +# note is Copyright (c) 1999-2004 Thomas Linden. # You can contact me per email: # # comments start with #, empty lines will be ignored. @@ -13,15 +13,10 @@ # by minimum one space (more spaces and/or tabs are allowed) -# Your home directory, better do not change it! -# can be an environment variable or a path -Home $ENV{'HOME'} - - # specify the path, where the NOTEDB lib directory # resides. This will only used if it is not # installed inside the perl-lib directory structure! -LibPath /usr/local/lib +#LibPath /usr/local/lib # you need to decide which database backend you want diff --git a/note.pod b/note.pod index be59b58..795a125 100644 --- a/note.pod +++ b/note.pod @@ -513,6 +513,6 @@ Thomas Linden =head1 VERSION -1.2.4 (19/03/2003) +1.2.5 (19/01/2004) =cut