aboutsummaryrefslogtreecommitdiffstats
path: root/ves-create.sh
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2026-06-06 12:27:03 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2026-06-06 12:27:03 -0400
commit0ecfe53b2d271133fac36de11ecfc0f7e47840f0 (patch)
tree3ee8b5188936e350e15ff851b07a33031d366389 /ves-create.sh
parent04b385284a8559bde3df51bab950784a0fd28cfd (diff)
downloadsh-ves-0ecfe53b2d271133fac36de11ecfc0f7e47840f0.tar.gz
Initial version complete
I dusted this off after years and had Claude finish it for me. caveat emptor: this is largely (though not entirely) LLM generated as of this commit
Diffstat (limited to 'ves-create.sh')
-rwxr-xr-x[-rw-r--r--]ves-create.sh29
1 files changed, 20 insertions, 9 deletions
diff --git a/ves-create.sh b/ves-create.sh
index b4f6467..11e6f05 100644..100755
--- a/ves-create.sh
+++ b/ves-create.sh
@@ -1,32 +1,43 @@
#!/bin/sh
+#
+# Create a new sh-ves environment. With --override, the variables listed
+# in SHVES_OVERRIDE_VARS (PATH, LDPATH, etc. by default) are initialized
+# to empty strings in the new environment, so activating it truncates them.
+#
_shves_create_env() {
file="$SHVES_ENV_DIR/$1"
- printf "name: $1\n" > $file
+ printf "name: %s\n" "$1" > "$file"
- if [ "$2" -eq "1" ]; then
+ if [ "$2" -eq 1 ]; then
for var in $SHVES_OVERRIDE_VARS; do
- printf "export_var:%s=\n" "$var" >> $file
+ printf "export_var:%s=\n" "$var" >> "$file"
done
fi
}
ves_create() {
+ override=0
+ case $1 in
+ --override)
+ override=1
+ shift
+ ;;
+ esac
+
if [ "$#" -lt 1 ]; then
- printf "ERROR: No environment name specified.\n" > /dev/stderr
+ printf "ERROR: No environment name specified.\n" >&2
return 1
fi
- override=0
env_name="$1"
- test "$#" -eq "2" && override=1
if ! _shves_check_env_name "$env_name"; then
- return 1;
+ return 1
fi
if _shves_check_env_exists "$env_name" 1; then
- printf "ERROR: Environment [%s] already exists.\n" "$env_name"
- return 1;
+ printf "ERROR: Environment [%s] already exists.\n" "$env_name" >&2
+ return 1
fi
_shves_create_env "$env_name" "$override"