Browse Source

Switched over to being bourne shell compatible

Samuel W. Flint 7 years ago
parent
commit
abc1aa3e26
1 changed files with 46 additions and 46 deletions
  1. 46 46
      library.org

+ 46 - 46
library.org

@@ -73,39 +73,39 @@ As a person who has a lot of books, I like to be able to keep track of them.  I'
 
   case ${COMMAND} in
       help)
-          display-help
+          display_help
           exit
           ;;
       query)
-          run-query $@
+          run_query $@
           exit
           ;;
       add)
-          add-single $@
+          add_single $@
           exit
           ;;
       git)
-          do-git $@
+          do_git $@
           exit
           ;;
       bulk-add)
-          bulk-add $@
+          bulk_add $@
           exit
           ;;
       report)
-          do-report $@
+          do_report $@
           exit
           ;;
       edit)
-          do-edit $@
+          do_edit $@
           exit
           ;;
       loan)
-           do-loan $@
+           do_loan $@
            exit
            ;;
       return-book)
-          do-return $@
+          do_return $@
           exit
           ;;
       init)
@@ -113,7 +113,7 @@ As a person who has a lot of books, I like to be able to keep track of them.  I'
           exit
           ;;
       ,*)
-          display-help
+          display_help
           exit
   esac
 #+END_SRC
@@ -182,7 +182,7 @@ The initialization of the database is accomplished by creating the containing di
       OLD=`pwd`
       mkdir -p ${LIBRARYDIRECTORY}
       cd ${LIBRARYDIRECTORY}
-      [[ -ne `basename ${LIBRARYFILE}` ]] && \
+      [[ ! -e `basename ${LIBRARYFILE}` ]] && \
           cat <<EOF > `basename ${LIBRARYFILE}`
   <<file-format>>
   EOF
@@ -201,7 +201,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Handle Git
 #+Name: handle-git
 #+BEGIN_SRC sh
-  function do-git {
+  function do_git {
       if [[ $# -lt 1 ]] ; then
           echo "library git args*"
           exit 1
@@ -232,7 +232,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Handle Query
 #+Name: handle-query
 #+BEGIN_SRC sh
-  function run-query {
+  function run_query {
       recsel -t Book $@ ${LIBRARYFILE}
   }
 #+END_SRC
@@ -246,22 +246,22 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Add Book
 #+Name: add-book
 #+BEGIN_SRC sh
-  function add-single {
+  function add_single {
       if [[ $# -lt 7 ]] ; then
-      echo -n "Title: "
-      read TITLE
-      echo -n "Author: "
-      read AUTHOR
-      echo -n "LCCN: "
-      read LCCN
-      echo -n "Copyright: "
-      read COPYRIGHT
-      echo -n "Publisher: "
-      read PUBLISHER
-      echo -n "ISBN: "
-      read ISBN
-      echo -n "Location: "
-      read LOCATION
+          echo -n "Title: "
+          read TITLE
+          echo -n "Author: "
+          read AUTHOR
+          echo -n "LCCN: "
+          read LCCN
+          echo -n "Copyright: "
+          read COPYRIGHT
+          echo -n "Publisher: "
+          read PUBLISHER
+          echo -n "ISBN: "
+          read ISBN
+          echo -n "Location: "
+          read LOCATION
       else
           TITLE=$1
           shift
@@ -287,8 +287,8 @@ This handles git as needed, by first checking to see if the first argument is ~i
              -f ISBN -v "${ISBN}" \
              -f Location -v "${LOCATION}" \
              ${LIBRARYFILE}
-      do-git add `basename ${LIBRARYFILE}`
-      do-git commit -m "Added record for \"${TITLE}\""
+      do_git add `basename ${LIBRARYFILE}`
+      do_git commit -m "Added record for \"${TITLE}\""
   }
 #+END_SRC
 
@@ -301,7 +301,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Add Books in Bulk
 #+Name: add-in-bulk
 #+BEGIN_SRC sh
-  function bulk-add {
+  function bulk_add {
       if [[ $@ -lt 1 ]] ; then
           echo "library bulk-add number"
           exit 1
@@ -310,11 +310,11 @@ This handles git as needed, by first checking to see if the first argument is ~i
       GIT=FALSE
       for i in {1..$1} ; do
           echo "Adding book number ${i}"
-          add-single
+          add_single
       done
       GIT=${GITOLD}
-      do-git add `basename ${LIBRARYFILE}`
-      do-git commit -m "Added ${1} records"
+      do_git add `basename ${LIBRARYFILE}`
+      do_git commit -m "Added ${1} records"
   }
 #+END_SRC
 
@@ -327,7 +327,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Reporting
 #+Name: handle-reports
 #+BEGIN_SRC sh
-  function do-report {
+  function do_report {
       if [[ $# -lt 1 ]] ; then
           echo "library report name args*"
           exit 1
@@ -368,7 +368,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Edit Fields
 #+Name: edit-field
 #+BEGIN_SRC sh
-  function do-edit {
+  function do_edit {
       if [[ $# -lt 2 ]] ; then
           echo "ledger edit id field [ value ]"
           exit 1
@@ -389,8 +389,8 @@ This handles git as needed, by first checking to see if the first argument is ~i
                  -f "${FIELD}" -s "${VALUE}" \
                  ${LIBRARYFILE}
       fi
-      do-git add `basename ${LIBRARYFILE}`
-      do-git commit -m "Edited record id ${ID}"
+      do_git add `basename ${LIBRARYFILE}`
+      do_git commit -m "Edited record id ${ID}"
   }
 #+END_SRC
 
@@ -403,7 +403,7 @@ This handles git as needed, by first checking to see if the first argument is ~i
 #+Caption: Handle Loaning
 #+Name: loan
 #+BEGIN_SRC sh
-  function do-loan {
+  function do_loan {
       if [[ $# -lt 2 ]] ; then
           echo "library loan id name"
           exit 1
@@ -420,11 +420,11 @@ This handles git as needed, by first checking to see if the first argument is ~i
       recset -e "ID = ${ID}" \
              -f "LoanOn" -S "`date +"%a, %d %b %Y %H:%M:%S %z"`" \
              ${LIBRARYFILE}
-      do-git add `basename ${LIBRARYFILE}`
-      do-git commit -m "Loaned Book ${ID} to ${NAME}"
+      do_git add `basename ${LIBRARYFILE}`
+      do_git commit -m "Loaned Book ${ID} to ${NAME}"
   }
 
-  function do-return {
+  function do_return {
       if [[ $# -lt 1 ]] ; then
           echo "library return-book id"
           exit 1
@@ -440,8 +440,8 @@ This handles git as needed, by first checking to see if the first argument is ~i
              -f "LoanOn" -d \
              ${LIBRARYFILE}
 
-      do-git add `basename ${LIBRARYFILE}`
-      do-git commit -m "Returned Book ${ID}"
+      do_git add `basename ${LIBRARYFILE}`
+      do_git commit -m "Returned Book ${ID}"
   }
 #+END_SRC
 
@@ -462,7 +462,7 @@ To complete this program, I include a help message, a small part of which is dis
       exit
   fi
 
-  function display-help {
+  function display_help {
       cat <<EOF
   library [ help | query | add | git | bulk-add | report | edit | loan | return-book | init ]
 
@@ -491,7 +491,7 @@ Finally, this is what puts the application together.  Placing each function in i
 
 #+Caption: Packaging
 #+Name: packaging
-#+BEGIN_SRC sh :tangle "~/bin/library" :shebang "#!/bin/zsh -f"
+#+BEGIN_SRC sh :tangle "~/bin/library" :shebang "#!/bin/sh"
   LIBRARYFILE=~/.library/library.rec
   LIBRARYDIRECTORY=~/.library
   GIT=detect