sm-sorcery AT lists.ibiblio.org
Subject: Discussion of Sorcery related topics
List archive
[SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13
- From: Sergey A Lipnevich <sergeyli AT pisem.net>
- To: rabrams AT cvs.sourcemage.org
- Cc: sm-sorcery AT lists.ibiblio.org
- Subject: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13
- Date: Thu, 24 Oct 2002 16:58:40 -0400
Ryan,
May I ask you to refrain from using "for i in <list>" construct when <list> is a multi-line entity, for example the output of `codex_get_all_grimoires`? You can use "echo <list> | while read i; do ...; done" or "while read i; do ...; done < echo <list>" instead, whichever you prefer, but please don't count on $IFS implicitly, or on the fact that lines in the <list> don't have whitespace. I daresay current "libcodex" may be a good example now that I cut out all $IFS-dependent stuff. Since you seem to be passing return values using "echo" instead of assigning global env variables, this must be a really easy change.
Thanks!
Sergey.
rabrams AT cvs.sourcemage.org wrote:
Update of /cvsroot/sourcemage/sourcemage/sorcery/usr/sbin
In directory claire:/tmp/cvs-serv17955/usr/sbin
Modified Files:
scribe Log Message:
Added swap, set, and index commands to scribe.
Index: scribe
===================================================================
RCS file: /cvsroot/sourcemage/sourcemage/sorcery/usr/sbin/scribe,v
retrieving revision 1.12
retrieving revision 1.13
diff -U2 -r1.12 -r1.13
--- scribe 2002/09/30 20:54:06 1.12
+++ scribe 2002/10/24 20:49:01 1.13
@@ -37,4 +37,112 @@
}
+##########################
+# Function: Index
+# Display installed grimoires
+#########################
+
+index() {
+
+echo "Codex Listing"
+echo "-------------"
+echo ""
+
+#get installed grimoires
+grimoires=`codex_get_all_grimoires`
+ +#for each grimoire
+let c=0
+for j in $grimoires; do
+ i=`basename "$j"`
+echo " [$c] : $i : $j"
+ c=$((c+1))
+done
+
+#echo ""
+#echo "The number in [] is the ID of the grimoire."
+#echo "Grimoires are searched in ascending order when looking for spells."
+#echo ""
+#echo "The second item is the \"basename\" of the grimoire,"
+#echo "or what it is referred to as."
+#echo ""
+#echo "The final item is the full path location of the grimoire."
+#echo "This will usually be in /var/lib/sorcery/codex"
+
+}
+
+#######################################
+#swap()
+#######################################
+swap(){
+
+#get installed grimoires
+grimoires=`codex_get_all_grimoires`
+ +#for each grimoire
+let c=0
+for j in $grimoires; do
+ i=`basename "$j"`
+if [ "$i" = "${ITEMS[0]}" ]; then
+ let p1=$c
+ i1=$j
+elif [ "$i" = "${ITEMS[1]}" ]; then
+ let p2=$c
+ i2=$j
+fi
+ c=$((c+1))
+done
+
+if [ -z "$p1" ]; then
+ echo "Error: ${ITEMS[0]} not found in codex"
+elif [ -z "$p2" ]; then
+ echo "Error: ${ITEMS[1]} not found in codex"
+else
+echo -n "swapping "
+ echo "${ITEMS[0]} with ${ITEMS[1]}"
+codex_add_grimoire $i1 $p2
+codex_add_grimoire $i2 $p1
+fi
+
+
+}
+
+
+######################################
+#set()
+######################################
+set(){
+
+#get installed grimoires
+grimoires=`codex_get_all_grimoires`
+ +#for each grimoire
+let c=0
+movemode="n"
+for j in $grimoires; do
+ i=`basename "$j"`
+#echo "testing $i"
+ if [ "$i" = "${ITEMS[0]}" ]; then
+ movemode="t"
+ tmove=$j
+# echo "movemode = $movemode"
+ fi
+# if [ ! "${ITEMS[0]}" -ne "$c" ]; then
+# nmove="$i"
+# fi
+ c=$((c+1))
+done
+
+echo -n "moving "
+#if [ $movemode == "n" ]; then
+# echo "id ${ITEMS[0]} ($nmove) to position ${ITEMS[1]}"
+#else
+ echo "${ITEMS[0]} to position ${ITEMS[1]}"
+codex_add_grimoire $tmove ${ITEMS[1]}
+
+#fi
+
+}
+
+
######################################
#add()
@@ -83,5 +191,5 @@
#switch to and work in the codex
- pushd $CODEX_ROOT
+ pushd $CODEX_ROOT > /dev/null
#download the grimoire using subroutines
@@ -488,4 +596,7 @@
r|re|rem|remo|remov|remove) FUNCTION="r" ;;
u|up|upd|upda|updat|update) FUNCTION="u" ;;
+ sw|swa|swap)
FUNCTION="swap";;
+ se|set) FUNCTION="set";;
+ i|in|ind|inde|index)
FUNCTION="index";;
*) #unrecognized
function. give help
help ;;
@@ -566,4 +677,7 @@
r) remove ;;
u) update ;;
+ set) set ;;
+ swap) swap ;;
+ index) index ;;
*) help ;;
esac
------------------
Get free mailbox 20 Mb at http://www.hotbox.ru
-
[SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Sergey A Lipnevich, 10/24/2002
-
[SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Ryan Abrams, 10/24/2002
-
[SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Sergey A Lipnevich, 10/24/2002
-
Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Ryan Abrams, 10/24/2002
-
Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Sergey A Lipnevich, 10/24/2002
-
Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Nick Jennings, 10/25/2002
- Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13, Sergey A Lipnevich, 10/25/2002
-
Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Nick Jennings, 10/25/2002
- Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13, Dufflebunk, 10/24/2002
-
Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Sergey A Lipnevich, 10/24/2002
-
Re: [SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Ryan Abrams, 10/24/2002
-
[SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Sergey A Lipnevich, 10/24/2002
-
[SM-Sorcery]Re: CVS: sourcemage/sorcery/usr/sbin scribe,1.12,1.13,
Ryan Abrams, 10/24/2002
Archive powered by MHonArc 2.6.24.