moved inc_num to a better place, cleaned up alias generation a bit,
authorChris Koeritz <fred@gruntose.com>
Thu, 9 Feb 2012 06:26:28 +0000 (01:26 -0500)
committerChris Koeritz <fred@gruntose.com>
Thu, 9 Feb 2012 06:26:28 +0000 (01:26 -0500)
automatically building correct PERLLIB now for our script folders.

scripts/core/common.alias
scripts/core/generate_aliases.pl
scripts/core/inc_num.pl [deleted file]
scripts/core/random_iter.sh [deleted file]
scripts/core/variables.sh
scripts/math/inc_num.pl [new file with mode: 0644]

index 54f0e95519c4292bd69c9a922c55fd3e05bd2497..a8c30c1e789f943bf0153eefa16cd056432df369 100644 (file)
@@ -49,7 +49,7 @@ alias play='bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh'
 alias bye='. $FEISTY_MEOW_SCRIPTS/users/goodbye.sh'
 
 # redoes fred's set of custom scripts.
-alias recustomize='cpdiff $FEISTY_MEOW_DIR/examples/custom_overrides/fred $FEISTY_MEOW_GENERATED/custom'
+alias recustomize='cpdiff $FEISTY_MEOW_DIR/examples/custom_overrides/fred $FEISTY_MEOW_GENERATED/custom; regenerate'
 # makes root user's home directory's permissions right.
 alias reroot='chown -R root:root /root'
 
@@ -79,9 +79,9 @@ alias why='echo just because.'
 
 # call the generated aliases file, if it exists.
 if [ -f "$FEISTY_MEOW_GENERATED/fmc_aliases_for_scripts.sh" ]; then 
-  if [ ! -z "$SHELL_DEBUG" ]; then echo launching generated aliases.; fi
+  if [ ! -z "$SHELL_DEBUG" ]; then echo loading script aliases...; fi
   source "$FEISTY_MEOW_GENERATED/fmc_aliases_for_scripts.sh"
-  if [ ! -z "$SHELL_DEBUG" ]; then echo done with generated aliases.; fi
+  if [ ! -z "$SHELL_DEBUG" ]; then echo done loading script aliases.; fi
 fi
 
 # remove the fredization macro if it was defined, helping to avoid running
index a97247e939dadf3164229f59ead0b494d3d18d28..082277c89ed8dac5864db8932a469a0c0990e31a 100644 (file)
@@ -130,7 +130,7 @@ print "made gener dir $FEISTY_MEOW_GENERATED\n";
   foreach $i (@ALIAS_DEFINITION_FILES) {
     open CURR_ALIASER, "<$i" or die "cannot open current alias file $i";
     foreach $line (<CURR_ALIASER>) {
-      print GENOUT "$line\n";
+      print GENOUT "$line";
     }
   }
 
@@ -170,11 +170,9 @@ if (-d $BINDIR) {
   system("chmod -R u+x \"$BINDIR\"/*");
 }
 
-
 # generate the first set of alias files that are defined in the core
 # and custom scripts directories.
 &rebuild_script_aliases;
-###system("bash \"$FEISTY_MEOW_SCRIPTS\"/core/unter_alia.sh");
 
 # trash the old versions.
 unlink("$FEISTY_MEOW_GENERATED/fmc_aliases_for_scripts.sh");
diff --git a/scripts/core/inc_num.pl b/scripts/core/inc_num.pl
deleted file mode 100644 (file)
index 4746115..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/perl
-
-###############################################################################
-#                                                                             #
-#  Name   : inc_num                                                           #
-#  Author : Chris Koeritz                                                     #
-#  Rights : Copyright (C) 1996-$now by Author                                 #
-#                                                                             #
-#  Purpose:                                                                   #
-#                                                                             #
-#    Operates on a number stored in a text file.  the number can be retrieved #
-#  for whatever purpose or it can be incremented.                             #
-#                                                                             #
-###############################################################################
-#  This program is free software; you can redistribute it and/or modify it    #
-#  under the terms of the GNU General Public License as published by the Free #
-#  Software Foundation; either version 2 of the License or (at your option)   #
-#  any later version.  See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
-#  version of the License.  Please send any updates to "fred@gruntose.com".   #
-###############################################################################
-
-# A number is retrieved from the passed in filename and returned.
-sub get_number {
-  local($number_file) = @_;
-#print "num file is $number_file\n";
-  open(NUMBERING, "$number_file");
-  local($number) = int(<NUMBERING>);
-  if ($number <= 0) { $number = 1; }
-  if ($number < 10) { $number = '0'.$number; }
-  if ($number < 100) { $number = '0'.$number; }
-  if ($number < 1000) { $number = '0'.$number; }
-  close(NUMBERING);
-  return $number;
-}
-
-# the number in the passed filename is increased.
-sub next_number {
-  local($number_file) = @_;
-  local($number) = &get_number($number_file);
-  if ($number < 0) { $number = '0000'; }
-  $number++;
-  if ($number > 9999) { $number = '0000'; }
-  open(NUMBERING, "> $number_file");
-#print "number is now $number\n";
-  print NUMBERING "$number\n";
-  close(NUMBERING);
-}
-
-# stores the number specified into the file specified.
-sub store_number {
-  local($number, $number_file) = @_;
-#print "storing $number into $number_file\n";
-  open(NUMBERING, "> $number_file");
-  print NUMBERING "$number\n";
-  close(NUMBERING);
-}
-
-1;
-
diff --git a/scripts/core/random_iter.sh b/scripts/core/random_iter.sh
deleted file mode 100644 (file)
index c8eaa9d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-COMMAND='play -v 10'
-
-COUNT=$#
-if [ $COUNT -ne 1 -o ! -d $1 ]; then
-       echo random_iter needs a directory name where the files to be randomly
-       echo chosen from are located.
-       \exit 0
-fi
-
-NUMBER_OF_FILES=$(ls -1 $1/* | wc | awk '{ print $1; }')
-
-if [ $NUMBER_OF_FILES -lt 1 ]; then
-       echo There are no files in $1.
-       \exit 0
-fi
-
-RANDOM_CHOICE=$(expr $RANDOM % $NUMBER_OF_FILES + 1)
-CURRENT_PLACE=1
-for i in $1/*; do
-  if [ $CURRENT_PLACE = $RANDOM_CHOICE ]; then
-    $COMMAND $i
-    \exit 0
-  fi
-  CURRENT_PLACE=$(expr $CURRENT_PLACE + 1)
-done
index 1894686c365b9de4159848827b3af1c3a5546420..d3d12f2a4a6c711bb95df0cf49ff16f084f72d06 100644 (file)
@@ -107,16 +107,29 @@ export PERLLIB
 if [ "$OS" != "Windows_NT" ]; then
   PERLLIB+="/usr/lib/perl5"
 else
+
 #echo "the scripts dir is $FEISTY_MEOW_SCRIPTS"
-  FEISTY_MEOW_SCRIPTS="$(echo $FEISTY_MEOW_SCRIPTS | sed -e 's/\\/\//g')"
-  FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_SCRIPTS"
+#  FEISTY_MEOW_SCRIPTS="$(echo $FEISTY_MEOW_SCRIPTS | sed -e 's/\\/\//g')"
+#  FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_SCRIPTS"
 #echo "the scripts dir is now $FEISTY_MEOW_SCRIPTS"
+
   export PERLIO=:perlio
-    # choose perl's IO over the system's so we can handle file bytes exactly.
+    # choose perl's IO over the ms-windows version so we can handle file
+    # bytes properly.
 fi
 
-#make this automatic!
-PERLLIB+=":$FEISTY_MEOW_SCRIPTS/core:$FEISTY_MEOW_SCRIPTS/text:$FEISTY_MEOW_SCRIPTS/files:$FEISTY_MEOW_SCRIPTS/archival"
+# iterate across our sub-directories and find the perl scripts.
+# this currently only looks one level down.
+for i in $FEISTY_MEOW_SCRIPTS/*; do
+  if [ -d "$i" ]; then
+    # check if there is a perl file present; add the folder to PERLLIB if so.
+    ls $i/*.pl &>/dev/null
+    if [ $? -eq 0 ]; then
+      PERLLIB+=":$i"
+    fi
+  fi
+done
+#echo PERLLIB is now $PERLLIB
 
 # set this so nechung can find its data.
 export NECHUNG=$LIBDIR/database/fortunes.dat
diff --git a/scripts/math/inc_num.pl b/scripts/math/inc_num.pl
new file mode 100644 (file)
index 0000000..4746115
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+###############################################################################
+#                                                                             #
+#  Name   : inc_num                                                           #
+#  Author : Chris Koeritz                                                     #
+#  Rights : Copyright (C) 1996-$now by Author                                 #
+#                                                                             #
+#  Purpose:                                                                   #
+#                                                                             #
+#    Operates on a number stored in a text file.  the number can be retrieved #
+#  for whatever purpose or it can be incremented.                             #
+#                                                                             #
+###############################################################################
+#  This program is free software; you can redistribute it and/or modify it    #
+#  under the terms of the GNU General Public License as published by the Free #
+#  Software Foundation; either version 2 of the License or (at your option)   #
+#  any later version.  See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
+#  version of the License.  Please send any updates to "fred@gruntose.com".   #
+###############################################################################
+
+# A number is retrieved from the passed in filename and returned.
+sub get_number {
+  local($number_file) = @_;
+#print "num file is $number_file\n";
+  open(NUMBERING, "$number_file");
+  local($number) = int(<NUMBERING>);
+  if ($number <= 0) { $number = 1; }
+  if ($number < 10) { $number = '0'.$number; }
+  if ($number < 100) { $number = '0'.$number; }
+  if ($number < 1000) { $number = '0'.$number; }
+  close(NUMBERING);
+  return $number;
+}
+
+# the number in the passed filename is increased.
+sub next_number {
+  local($number_file) = @_;
+  local($number) = &get_number($number_file);
+  if ($number < 0) { $number = '0000'; }
+  $number++;
+  if ($number > 9999) { $number = '0000'; }
+  open(NUMBERING, "> $number_file");
+#print "number is now $number\n";
+  print NUMBERING "$number\n";
+  close(NUMBERING);
+}
+
+# stores the number specified into the file specified.
+sub store_number {
+  local($number, $number_file) = @_;
+#print "storing $number into $number_file\n";
+  open(NUMBERING, "> $number_file");
+  print NUMBERING "$number\n";
+  close(NUMBERING);
+}
+
+1;
+