From: Chris Koeritz Date: Thu, 9 Feb 2012 06:26:28 +0000 (-0500) Subject: moved inc_num to a better place, cleaned up alias generation a bit, X-Git-Tag: 2.140.90~1631 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=11f798e2d290397e5b4f1f4d2bb7512819a76a9f;p=feisty_meow.git moved inc_num to a better place, cleaned up alias generation a bit, automatically building correct PERLLIB now for our script folders. --- diff --git a/scripts/core/common.alias b/scripts/core/common.alias index 54f0e955..a8c30c1e 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -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 diff --git a/scripts/core/generate_aliases.pl b/scripts/core/generate_aliases.pl index a97247e9..082277c8 100644 --- a/scripts/core/generate_aliases.pl +++ b/scripts/core/generate_aliases.pl @@ -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 () { - 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 index 4746115c..00000000 --- a/scripts/core/inc_num.pl +++ /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(); - 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 index c8eaa9d8..00000000 --- a/scripts/core/random_iter.sh +++ /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 diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index 1894686c..d3d12f2a 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -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 index 00000000..4746115c --- /dev/null +++ b/scripts/math/inc_num.pl @@ -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(); + 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; +