From 11f798e2d290397e5b4f1f4d2bb7512819a76a9f Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Thu, 9 Feb 2012 01:26:28 -0500 Subject: [PATCH] moved inc_num to a better place, cleaned up alias generation a bit, automatically building correct PERLLIB now for our script folders. --- scripts/core/common.alias | 6 +++--- scripts/core/generate_aliases.pl | 4 +--- scripts/core/random_iter.sh | 26 -------------------------- scripts/core/variables.sh | 23 ++++++++++++++++++----- scripts/{core => math}/inc_num.pl | 0 5 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 scripts/core/random_iter.sh rename scripts/{core => math}/inc_num.pl (100%) 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/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/core/inc_num.pl b/scripts/math/inc_num.pl similarity index 100% rename from scripts/core/inc_num.pl rename to scripts/math/inc_num.pl -- 2.34.1