From: "Amadeusz Żołnowski" <aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
To: "Amadeusz Żołnowski" <aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 2/2] 60xen: use 'hash' instead of 'type'
Date: Wed, 18 Aug 2010 17:31:03 +0200 [thread overview]
Message-ID: <20100818173103.27a444da@aidecoe.name> (raw)
In-Reply-To: <20100818172944.3244c1e0-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1439 bytes --]
---
modules.d/60xen/check | 9 +++++----
modules.d/60xen/install | 7 +++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/modules.d/60xen/check b/modules.d/60xen/check
index 49d5435..6b9cabe 100755
--- a/modules.d/60xen/check
+++ b/modules.d/60xen/check
@@ -1,14 +1,15 @@
#!/bin/bash
# No Xen-detect? Boo!!
-XENDETECT=$(type -P xen-detect)
-[ -z "$XENDETECT" ] && [ -d "/usr/lib/xen-default" ] && XENDETECT="/usr/lib/xen-default/bin/xen-detect"
-[ -z "$XENDETECT" ] && exit 1
+if ! hash xen-detect 2>/dev/null; then
+ [[ -d /usr/lib/xen-default ]] && \
+ hash -p /usr/lib/xen-default/bin/xen-detect xen-detect || exit 1
+fi
. $dracutfunctions
[[ $debug ]] && set -x
# Yes, we are under Xen PV env.
-$XENDETECT | egrep -q -v 'PV' || exit 0
+xen-detect | grep -q -v PV || exit 0
exit 1
diff --git a/modules.d/60xen/install b/modules.d/60xen/install
index 22f5329..6ae0060 100755
--- a/modules.d/60xen/install
+++ b/modules.d/60xen/install
@@ -1,6 +1,5 @@
#!/bin/bash
-XENDETECT=$(type -P xen-detect)
-[ -z "$XENDETECT" ] && [ -d "/usr/lib/xen-default" ] && XENDETECT="/usr/lib/xen-default/bin/xen-detect"
-inst $XENDETECT /sbin/xen-detect
+hash xen-detect 2>/dev/null || \
+ hash -p /usr/lib/xen-default/bin/xen-detect xen-detect
+inst "$(hash -t xen-detect)" /sbin/xen-detect
inst_hook pre-udev 40 "$moddir/xen-pre-udev.sh"
-
--
1.7.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2010-08-18 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 15:29 [PATCH 1/2] use 'type' built-in instead of external cmd 'which' in every Bash script Amadeusz Żołnowski
[not found] ` <20100818172944.3244c1e0-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
2010-08-18 15:31 ` Amadeusz Żołnowski [this message]
2010-08-23 10:41 ` Harald Hoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100818173103.27a444da@aidecoe.name \
--to=aidecoe-2qtfh70ttyba5ebddlwbiw@public.gmane.org \
--cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.