From 17cbf2a542dafde1863bfb642281d02d9c7d2f85 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 12 Apr 2015 15:54:49 -0400 Subject: [PATCH] enhancement to spacem macro to not allow non-existent files. --- scripts/core/functions.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index b068210c..c38bc7f4 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -382,25 +382,12 @@ if [ -z "$skip_all" ]; then function spacem() { -#hmmm: could really use that pattern of 'iterate across all the arguments and do same thing' here. - -#hmmm: it actually seems like the below IS the pattern. it's pretty short, but i wish it could be shorter, like a function in itself.... ah. -# couldn't we have a functionator deal that takes: -# 1) a command to run, and -# 2-n) arguments, -# where the function just blithely runs that command on all of those arguments!? -# yes! that does seem like the pattern being sought, much nicer than the goofy loop below, -# although this functionator deal needs to handle when there are more than one command also, -# or this very function couldn't be implemented... -# maybe a two step process: -# 1) build a list of commands to run on all arguments, -# 2) then run through all the arguments passed in using those established commands. -# yes again! this seems like it would meet all the needs involved and not be too irksome. -# for the example below, this would reduce the number of lines, i think. -# i had better stop bloviating and write this function so i can determine the number of -# lines omitted by the new approach. while [ $# -gt 0 ]; do arg="$1"; shift + if [ ! -f "$arg" -a ! -d "$arg" ]; then + echo "failure to find a file or directory named '$arg'." + continue + fi # first we rename the file to be lower case. perl $FEISTY_MEOW_SCRIPTS/files/renlower.pl "$arg" &>/dev/null # oops, now the name is all lower-case. we need to make the @@ -415,7 +402,6 @@ if [ -z "$skip_all" ]; then # printout the combined operation results. echo "'$arg' => $final_name" done -# } ############## -- 2.34.1