From 39e386e9dcbe8b5ef762af10354be6d19110776c Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 20 Dec 2021 18:55:15 -0500 Subject: ves.sh: Turned ves into a function --- Makefile | 4 +++ ves.sh | 113 ++++++++++++++++++++++++++++++++------------------------------- 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index d55de6e..6239d48 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ endif BIN_DIR=$(HOME)/.local/bin +# TODO: ves needs to be installed as a function in the user's +# shell. This will require making updates to their configuration +# file as part of the install process, which will require a bit +# of extra work. install: - test -d $(DATA_DIR)/ves/bin || mkdir -p $(DATA_DIR)/ves/bin - test -d $(DATA_DIR)/ves/lib || mkdir -p $(DATA_DIR)/ves/lib diff --git a/ves.sh b/ves.sh index 49ac263..0287a8a 100644 --- a/ves.sh +++ b/ves.sh @@ -1,59 +1,60 @@ #!/bin/sh +ves() { + if [ -z "$VES_SCRIPTS_DIR" ]; then + VES_BIN="$HOME/.local/bin/ves_scripts" + else + VES_BIN="$VES_SCRIPTS_DIR" + fi -if [ -z "$VES_SCRIPTS_DIR" ]; then - VES_BIN="$HOME/.local/bin/ves_scripts" -else - VES_BIN="$VES_SCRIPTS_DIR" -fi - -# extract the appropriate command -case $1 in - create) - shift - $VES_BIN/ves-create.sh $@ - break - ;; - delete) - shift - $VES_BIN/ves-delete.sh $@ - break - ;; - var-add) - shift - $VES_BIN/ves-addvar.sh $@ - break - ;; - var-rm) - shift - $VES_BIN/ves-rmvar.sh $@ - break - ;; - export) - shift - $VES_BIN/ves-export.sh $@ - break - ;; - list) - shift - $VES_BIN/ves-list.sh $@ - break - ;; - activate) - shift - $VES_BIN/ves-activate.sh $@ - break - ;; - deactivate) - shift - $VES_BIN/ves-deactivate.sh $@ - break - ;; - prompt) - shift - $VES_BIN/ves-prompt.sh $@ - break - ;; - *) - printf "ERROR: Invalid command [%s]\n" $1 > /dev/stderr -esac + # extract the appropriate command + case $1 in + create) + shift + . $VES_BIN/ves-create.sh $@ + break + ;; + delete) + shift + . $VES_BIN/ves-delete.sh $@ + break + ;; + var-add) + shift + . $VES_BIN/ves-addvar.sh $@ + break + ;; + var-rm) + shift + . $VES_BIN/ves-rmvar.sh $@ + break + ;; + export) + shift + . $VES_BIN/ves-export.sh $@ + break + ;; + list) + shift + . $VES_BIN/ves-list.sh $@ + break + ;; + activate) + shift + . $VES_BIN/ves-activate.sh $@ + break + ;; + deactivate) + shift + . $VES_BIN/ves-deactivate.sh $@ + break + ;; + prompt) + shift + . $VES_BIN/ves-prompt.sh $@ + break + ;; + *) + printf "ERROR: Invalid command [%s]\n" $1 > /dev/stderr + esac +} -- cgit v1.2.3