summaryrefslogtreecommitdiff
path: root/bin/pkg
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-06-01 21:40:35 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2008-06-01 21:40:35 +0200
commit90202ba79e338d142b0c4f951ff34bdfb65ede5c (patch)
tree80083fc01c93c5836cab3f8a0c7363d9ba45c688 /bin/pkg
parent08b8086180bb9bf27b257e62e2ec583296bf317a (diff)
bin/pkg: Use confirm_{yes,no} instead of read
Diffstat (limited to 'bin/pkg')
-rwxr-xr-xbin/pkg20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/pkg b/bin/pkg
index e345823..494e922 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -27,6 +27,18 @@ die () {
exit 100
}
+confirm_yes () {
+ echo -n "${info}$*${reset} [Y/n] "
+ read -q
+ [ -z "$REPLY" ] && true
+}
+
+confirm_no () {
+ echo -n "${error}$*${reset} [y/N] "
+ read -q
+}
+
+
check_sed () {
QUUX=$(echo foox | sed -r 's/^fo{2}(.)$/quu\1/' 2> /dev/null)
if ([ "$QUUX" != 'quux' ]) {
@@ -55,9 +67,7 @@ check_deps () {
return 100
}
if ([ ! -d $PDIR/$dep ]) {
- echo -n "$1 depends on $dep. Install dependency? [Y/n] "
- read
- if ([ ! "$REPLY" = 'n' ]) {
+ if (confirm_yes "$1 depends on $dep. Install dependency?") {
INSTALL+="$dep"
}
}
@@ -101,9 +111,7 @@ pkg_remove () {
cd $PDIR/$1
if ([ -r priority ]) {
if ([ $(cat priority) -gt 3 ]) {
- warn "Package '$1' is $(real_priority $(cat priority)). Really remove? [y/N] "
- read
- [ "$REPLY" = 'y' ] || return
+ confirm_no "Package '$1' is $(real_priority $(cat priority)). Really remove?" || return
}
}
if ([ -f $PDIR/$1/hooks/pre-remove ]) {