about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-02-24 19:58:49 +0100
committerSoispha <soispha@vhack.eu>2024-02-24 19:58:49 +0100
commit49a1622ad8b9545c043a5a6ba7c46ea37b95b0f0 (patch)
treea2221528d0b1c2319c448ca4aebb5b8fd80dd6d8
parentchore(version): v1.33.2 (diff)
downloadnixos-config-49a1622ad8b9545c043a5a6ba7c46ea37b95b0f0.tar.gz
nixos-config-49a1622ad8b9545c043a5a6ba7c46ea37b95b0f0.zip
fix(hm/conf/lf/cmds): Better manage files with pre-defined extensions
Diffstat (limited to '')
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/archive.sh17
-rwxr-xr-xhm/soispha/conf/lf/commands/scripts/mk_scr_default.sh9
2 files changed, 14 insertions, 12 deletions
diff --git a/hm/soispha/conf/lf/commands/scripts/archive.sh b/hm/soispha/conf/lf/commands/scripts/archive.sh
index 27947d6f..e437dad2 100755
--- a/hm/soispha/conf/lf/commands/scripts/archive.sh
+++ b/hm/soispha/conf/lf/commands/scripts/archive.sh
@@ -36,9 +36,10 @@ esac
 
 prompt "Archive name: "
 name=""
-while [ -z "$name" ] || [ -e "$name.$ext" ]; do
-    read -r name
-    if [ -e "$name.$ext" ]; then
+while [ -z "$name" ] || [ -e "$name" ]; do
+    read -r name_base
+    name="$name_base.$ext"
+    if [ -e "$name" ]; then
         prompt "Archive already exists, overwrite [y|N]: "
         read -r ans
 
@@ -60,17 +61,17 @@ done <"$(tmp echo "$fx")"
 
 case "$archiver" in
 "gzip")
-    tar --create --gzip -file="$name".tar.gz "$@"
+    tar --create --gzip -file="$name" "$@"
     ;;
 "xz")
-    tar --create --file="$name".tar "$@"
-    xz --compress -9 --extreme --threads=0 "$name".tar
+    tar --create --file="$name" "$@"
+    xz --compress -9 --extreme --threads=0 "$name"
     ;;
 "7z")
-    7z a "$name".7z "$@"
+    7z a "$name" "$@"
     ;;
 "zip")
-    zip --symlinks -9 -r "$name".zip "$@"
+    zip --symlinks -9 -r "$name" "$@"
     ;;
 esac
 # vim: ft=sh
diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh
index 6ceed95e..bc57563c 100755
--- a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh
+++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh
@@ -14,9 +14,10 @@ id="$id"
 
 prompt "Script name: "
 name=""
-while [ -z "$name" ] || [ -e "$name.sh" ]; do
-    read -r name
-    if [ -e "$name.sh" ]; then
+while [ -z "$name" ] || [ -e "$name" ]; do
+    read -r name_base
+    name="$name_base.sh"
+    if [ -e "$name" ]; then
         prompt "Script already exists, overwrite [y|N]: "
         read -r ans
 
@@ -30,7 +31,7 @@ done
 
 script="$(pwd)"/"$name"
 
-cat "%SHELL_LIBRARY_TEMPLATE" >"$script.sh"
+cat "%SHELL_LIBRARY_TEMPLATE" >"$script"
 chmod +x "$script"
 "$VISUAL" "$script"