aboutsummaryrefslogtreecommitdiff
path: root/utils/ask
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2025-12-10 12:19:17 +0100
committerKarel Kočí <cynerd@email.cz>2025-12-10 12:19:17 +0100
commit71170ba96ad788726af419edd64d58bdfe5b52b5 (patch)
tree1773ebe943c4885a2b419fb1dfd7da3afb8421ab /utils/ask
parent60fc87b4003f5d047aafa970d62416a93801a5c9 (diff)
downloadmyconfigs-71170ba96ad788726af419edd64d58bdfe5b52b5.tar.gz
myconfigs-71170ba96ad788726af419edd64d58bdfe5b52b5.tar.bz2
myconfigs-71170ba96ad788726af419edd64d58bdfe5b52b5.zip
Format and add guix installHEADmaster
Diffstat (limited to 'utils/ask')
-rw-r--r--utils/ask24
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/ask b/utils/ask
new file mode 100644
index 0000000..4b47c7e
--- /dev/null
+++ b/utils/ask
@@ -0,0 +1,24 @@
+# vim: ft=sh
+
+# Ask if given section should be installed
+# First argument is name (take care not to use special characters for regulard
+# expression) and second argument is a question
+ask() {
+ local ignore_file
+ ignore_file=".ignore-$(hostname)"
+ [ -f "$ignore_file" ] && grep -q "^$1$" "$ignore_file" && return 1
+ if $FORCE; then
+ echo "\e[1;34m$2\e[0m"
+ # Fall trough with 0 exit (always yes)
+ else
+ echo -e -n "\e[1;34m$2? (Y/n) \e[0m"
+ local reply
+ read -r reply
+ echo "$reply" | grep -qE '^[Yy]?$'
+ fi
+}
+
+# Check if command is available
+hascmd() {
+ command -v "$1" >/dev/null 2>&1
+}