[lxc-devel] [PATCH] use which instead of type in checking for command existence
Dwight Engen
dwight.engen at oracle.com
Tue Jan 22 17:21:58 UTC 2013
On Tue, 22 Jan 2013 10:18:44 -0600
Serge Hallyn <serge.hallyn at canonical.com> wrote:
> Quoting Dwight Engen (dwight.engen at oracle.com):
> > Use type instead of which for consistency with the rest of lxc, and
>
> Had me confused for a second due to the backward description :)
Yes, sorry about that.
> > also because type checks for shell builtins, a behavior that we do
> > not want in these cases.
> >
> > Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
>
> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
>
> Though while you're doing this,
>
> > ---
> > templates/lxc-busybox.in | 2 +-
> > templates/lxc-ubuntu.in | 4 ++--
> > 2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
> > index f2751d8..21092de 100644
> > --- a/templates/lxc-busybox.in
> > +++ b/templates/lxc-busybox.in
> > @@ -149,7 +149,7 @@ configure_busybox()
> > {
> > rootfs=$1
> >
> > - type busybox >/dev/null
> > + which busybox >/dev/null
> >
> > if [ $? -ne 0 ]; then
> > echo "busybox executable is not accessible"
> > diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in
> > index 0ed8808..6f9aafb 100644
> > --- a/templates/lxc-ubuntu.in
> > +++ b/templates/lxc-ubuntu.in
> > @@ -609,7 +609,7 @@ arch=$(arch)
> > # Code taken from debootstrap
> > if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture
> > >/dev/null 2>&1; then arch=`/usr/bin/dpkg --print-architecture`
> > -elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture
> > >/dev/null 2>&1; then +elif which udpkg >/dev/null 2>&1 && udpkg
> > >--print-architecture >/dev/null 2>&1; then
> > arch=`/usr/bin/udpkg --print-architecture`
Just noticed this, since we just figured out udpkg is in $PATH, why
use /usr/bin/udpkg with absolute path?
> > else
> > arch=$(arch)
> > @@ -666,7 +666,7 @@ if [ $hostarch = "i386" -a $arch = "amd64" ];
> > then exit 1
> > fi
> >
> > -type debootstrap
> > +which debootstrap
>
> Long as you're changing this, may as well > /dev/null 2>&1 ?
Yep, I'll supply a new patch shortly.
> > if [ $? -ne 0 ]; then
> > echo "'debootstrap' command is missing"
> > exit 1
> > --
> > 1.7.12.3
> >
> >
> > ------------------------------------------------------------------------------
> > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills
> > current with LearnDevNow - 3,200 step-by-step video tutorials by
> > Microsoft MVPs and experts. ON SALE this month only -- learn more
> > at: http://p.sf.net/sfu/learnnow-d2d
> > _______________________________________________
> > Lxc-devel mailing list
> > Lxc-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/lxc-devel
More information about the lxc-devel
mailing list