Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit1ad731f7f197e9a11891e2903e19b90fcbbc9de1 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-03-28 19:15:27 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-03-28 19:15:27 +0200
Fileseca63511b34fbe2793350c0c35a2a32bebb5fe61
.files-1ad731f7f197e9a11891e2903e19b90fcbbc9de1.tar
.files-1ad731f7f197e9a11891e2903e19b90fcbbc9de1.tar.gz
.files-1ad731f7f197e9a11891e2903e19b90fcbbc9de1.zip
Parentbb35aad51d0338bc919adb1ccd3e5effcb3c4499 (diff)
feat(install.sh): Move copy.sh logic to install.sh
2 files changed, 13 insertions, 27 deletions
-rwxr-xr-xcopy.sh24
-rwxr-xr-xinstall.sh16
diff --git a/copy.sh b/copy.sh
deleted file mode 100755
index c07f01f..0000000
--- a/copy.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-
-while read -r conf
-do
- [ -z "$conf" ] && continue
- [ ! -f "$conf" ] && echo "warning: $conf is not a regular file, skipping!" && continue
-
- dest="$HOME/$conf"
- if [ -f "$dest" ] && ! cmp --silent -- "$dest" "$conf"
- then
- diff "$dest" "$conf"
- printf "Files $dest and $conf are not the same! Overwrite? [y/N] "
- read -n1 overwrite </dev/tty
- echo
- [ "$overwrite" != 'y' && "$overwrite" != 'Y' ] && continue
- fi
-
- dir="$(dirname "$dest")"
- [ ! -d "$dir" ] && mkdir -p "$dir" || rm "$dest" >/dev/null 2>&1
- cp "$PWD/$conf" "$dest"
- echo "Installed ${conf##\./}"
-done <<EOF
-$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh' -not -name 'copy.sh')
-EOF
diff --git a/install.sh b/install.sh
index 19ca65b..6800966 100755
--- a/install.sh
+++ b/install.sh
@@ -1,11 +1,20 @@
#!/usr/bin/env bash
+copy=""
+while [ -n "$1" ]
+do
+ case "$1" in
+ (cp | copy) copy="yes" ;;
+ esac
+ shift
+done
+
while read -r conf
do
[ -z "$conf" ] && continue
[ ! -f "$conf" ] && echo "warning: $conf is not a regular file, skipping!" && continue
- dest="$HOME/$conf"
+ dest="$HOME/${conf##\./}"
if [ -f "$dest" ] && ! cmp --silent -- "$dest" "$conf"
then
diff "$dest" "$conf"
@@ -17,8 +26,9 @@ do
dir="$(dirname "$dest")"
[ ! -d "$dir" ] && mkdir -p "$dir" || rm "$dest" >/dev/null 2>&1
- ln -s "$PWD/$conf" "$dest"
+
+ [ -n "$copy" ] && cp "$PWD/$conf" "$dest" || ln -s "$PWD/$conf" "$dest"
echo "Installed ${conf##\./}"
done <<EOF
-$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh' -not -name 'copy.sh')
+$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh')
EOF