From 42c34cc1c1177096e5f7bbee13dd0cebf411ddd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ibhear=20=C3=93=20hAnluain?= Date: Mon, 23 Sep 2019 13:13:37 +0100 Subject: [PATCH] Making it a little more explicit what the commands being executed are. --- simple-setup.sh | 75 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/simple-setup.sh b/simple-setup.sh index 9860b5c..1f8207b 100755 --- a/simple-setup.sh +++ b/simple-setup.sh @@ -1,5 +1,6 @@ #!/bin/bash +# A function to make a statement. declaim () { echo echo ${*} @@ -7,6 +8,35 @@ declaim () { echo } +# A function to print the git command to be executed and then to +# execute it +git_command() { + # Print out the command. + echo + echo "git command: ${*}" + + # Some variable initialisations + COMMANDSTRING="${*}" + counter=0 + UNDERLINESTRING="" + + # Build UNDERLINESTRING to be a string of '-' characters the same + # length of all the options passed in. + while [ ${counter} -lt ${#COMMANDSTRING} ] + do + UNDERLINESTRING="${UNDERLINESTRING}-" + counter=$(( ${counter} + 1 )) + done + + # Print the pretty underline + echo -n " " + echo ${UNDERLINESTRING} + echo + + # Execute the command. + eval ${*} +} + SCRIPT_DIR=$(cd $(dirname ${0}); pwd) REPO_DIR=${SCRIPT_DIR}/simpleRepo @@ -23,10 +53,11 @@ mkdir -vp ${REPO_DIR} cd ${REPO_DIR} declaim "Initialising it as a git repository" -git init . +git_command git init ${REPO_DIR} -git config --local user.name "Gaius Julius Caesar" -git config --local user.email "gjcaesar@pontifexmaximus.rm" +declaim "Setting user.name and user.email for this local repository" +git_command git config --local user.name "\"Gaius Julius Caesar\"" +git_command git config --local user.email gjcaesar@pontifexmaximus.rm declaim "Creating a text file" cat < information.md @@ -38,27 +69,27 @@ This is a file for demonstration purposes EOF declaim "Adding and commiting that text file. The first commit" -git add information.md -git commit -m "commit1" +git_command git add information.md +git_command git commit -m "\"commit1\"" declaim "Updating the text file" echo "This is a second line of information." >> information.md echo >> information.md declaim "Adding and commiting that text file. The second commit" -git add information.md -git commit -m "commit2" +git_command git add information.md +git_command git commit -m "\"commit2\"" declaim "Updating the text file for the second time" echo "This is a third line of information." >> information.md echo >> information.md declaim "Adding and commiting that text file. The third commit" -git add information.md -git commit -m "commit3" +git_command git add information.md +git_command git commit -m "\"commit3\"" declaim "Creating and checking out the Rel1 branch" -git checkout -b Rel1 +git_command git checkout -b Rel1 declaim "Updating the text file on the Rel1 branch" cat <> information.md @@ -70,8 +101,8 @@ This is more information added as part of Rel1 EOF declaim "Adding and commiting that text file. The fourth commit" -git add information.md -git commit -m "commit4" +git_command git add information.md +git_command git commit -m "\"commit4\"" declaim "Updating the text file on the Rel1 branch again" mv -v information.md{,.hold} @@ -79,12 +110,12 @@ cat information.md.hold | sed 's/of Rel1$/of Rel1./' > information.md rm information.md.hold declaim "Adding and commiting that text file. The fifth commit" -git add information.md -git commit -m "commit5" +git_command git add information.md +git_command git commit -m "\"commit5\"" declaim "Creating and checking out the Rel2 branch" -git checkout master -git checkout -b Rel2 +git_command git checkout master +git_command git checkout -b Rel2 declaim "Updating the text file on the Rel2 branch" mv information.md{,.hold} @@ -99,8 +130,8 @@ cat information.md.hold >> information.md rm information.md.hold declaim "Adding and commiting that text file. The sixth commit" -git add information.md -git commit -m "commit6" +git_command git add information.md +git_command git commit -m "\"commit6\"" declaim "Updating the text file on the Rel2 branch again" mv information.md{,.hold} @@ -108,10 +139,10 @@ cat information.md.hold | sed 's/of Rel2$/of Rel2./' > information.md rm information.md.hold declaim "Adding and commiting that text file. The seventh commit" -git add information.md -git commit -m "commit7" +git_command git add information.md +git_command git commit -m "\"commit7\"" declaim "Checking out master" -git checkout master +git_command git checkout master -git log --oneline --graph --decorate --all +git_command git log --oneline --graph --decorate --all