summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Scott <scottj@sou.edu>2020-11-22 11:16:09 -0800
committerJake Scott <scottj@sou.edu>2020-11-22 11:16:09 -0800
commitdef41d86ed5c0007681a709e0dfcf08807d58881 (patch)
tree16884f183481ebfab0e88056c7e0ec462972f8a5
parent7302876b2a26eb4f8569e2280228831fc8f35b4b (diff)
added ls and init commands
-rw-r--r--README.md7
-rwxr-xr-xinit25
-rwxr-xr-xls3
3 files changed, 35 insertions, 0 deletions
diff --git a/README.md b/README.md
index 473845f..aef2c4b 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,8 @@
# git-shell commands
+
+Required functionality:
+
+help - usage messages
+ls - list all repositories
+init - create a new repository
+rm - remove a repository
diff --git a/init b/init
new file mode 100755
index 0000000..da5243b
--- /dev/null
+++ b/init
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+if [ $# -ne 1 ]; then
+ echo "usage: init <name>"
+ exit 1
+fi
+
+base_dir="$HOME"
+new_repo="$1"
+
+case $new_repo in
+ *\.git)
+ ;;
+ *)
+ new_repo="${new_repo}.git"
+ ;;
+esac
+
+if [ -d "$new_repo" ]; then
+ echo "$new_repo already exists"
+ exit 1
+fi
+
+mkdir "$base_dir/$new_repo"
+git init --bare "$base_dir/$new_repo"
diff --git a/ls b/ls
new file mode 100755
index 0000000..8b3b6d5
--- /dev/null
+++ b/ls
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ls -1 *\.git | cut -d. -f1