Best way to determine sudo in xeno-load?
Hi
Since the last checkin in xeno-load.in by gpm on the 17 of July my PPC HCU3 target does not run the xeno-tests correctly.
E.g. in http://ngiger.dyndns.org/buildbot/hcu3_q/builds/26/step-xenotest/0
you find lines like/usr/xenomai/bin/xeno-load: /usr/xenomai/bin/xeno-load: 249: sudo: not found
My earlier solution was:
if test -n "which sudo"; then
sudo=which sudo
fi
This was corrected by Gilles to
Quoted 5 lines
if test -n "
which sudo 2>/dev/null"; then
sudo=which sudo
elif test -n "type -t sudo 2>/dev/null"; then
sudo=sudo
fi
Unfortunately my busybox version 1.1.3 behaves like this:
Quoted 3 lines
~ $ type -t sudo 2>/dev/null
-t: not found
sudo: not found
Whereas my bash shell on my Debian system answers like this:
Quoted 2 lines
$ type -t sudo file
Therefore I propose to change it like this:
Quoted 8 lines
if test -n "
which sudo 2>/dev/null"; then
sudo=which sudo
elif "type -t sudo 2>/dev/null" = 'file'; then
sudo=sudo
else
sudo=
fi
echo sudo cmd is now $sudo
Which gives me in Debian's bash the following output:
Quoted 1 line
sudo cmd is now
/usr/bin/sudo
and running under the busybox
Quoted 3 lines
/usr/xenomai/bin/xeno-load:/usr/xenomai/bin/xeno-load: 59: -t: not found
sudo: not found: not found
sudo cmd is now
which is ugly, but at least does the job correctly.
Or is Gilles patch based on yet another use-case. If this is the case, please let me know.
Also, the test has to be moved up before the first use of the sudo command.
If nobody comes up with a better solution, I would ask somebody to apply the attached patch, which implements both ideas.
Best regards
Signature · 1 line
Niklaus Giger
xeno-load.in +9 -6
@@ -82,6 +82,15 @@ eval $user_moddir +if test -n "`which sudo 2>/dev/null`"; then + sudo=`which sudo` +elif "`type -t sudo 2>/dev/null`" = 'file'; then + sudo=sudo +else + sudo= +fi +echo sudo cmd is now $sudo + if `$sudo $modprobe -nq xeno_nucleus > /dev/null 2>&1`; then target_deps="${target_deps}nucleus+" else
@@ -94,12 +103,6 @@ test $verbose = 1 && echo "Running $target_name from $run_info_file" -if test -n "`which sudo 2>/dev/null`"; then - sudo=`which sudo` -elif test -n "`type -t sudo 2>/dev/null`"; then - sudo=sudo -fi - if test \! "x$target_mesg" = x; then case "$target_mesg" in control_c)
Quoted 13 lines · Niklaus Giger
Hi
Since the last checkin in xeno-load.in by gpm on the 17 of July my PPC HCU3 target does not run the xeno-tests correctly.
E.g. in http://ngiger.dyndns.org/buildbot/hcu3_q/builds/26/step-xenotest/0
you find lines like/usr/xenomai/bin/xeno-load:/usr/xenomai/bin/xeno-load: 249: sudo: not foundMy earlier solution was:
if test -n "which sudo"; then
sudo=which sudo
fi
Quoted 11 lines
This was corrected by Gilles to
Quoted 5 lines
if test -n "
which sudo 2>/dev/null"; then
sudo=which sudo
elif test -n "type -t sudo 2>/dev/null"; then
sudo=sudo
fiUnfortunately my busybox version 1.1.3 behaves like this:
Quoted 3 lines
~ $ type -t sudo 2>/dev/null
-t: not found
sudo: not found
What about:
if type sudo > /dev/null 2>&1; then
sudo=sudo
fi
Signature · 1 line
Gilles Chanteperdrix.
Am Mittwoch, 6. September 2006 23:08 schrieb Gilles Chanteperdrix:
Quoted 29 lines
Quoted 17 lines · Niklaus Giger
Hi
Since the last checkin in xeno-load.in by gpm on the 17 of July my PPC HCU3 target does not run the xeno-tests correctly.
E.g. in
http://ngiger.dyndns.org/buildbot/hcu3_q/builds/26/step-xenotest/0 you find lines like/usr/xenomai/bin/xeno-load:/usr/xenomai/bin/xeno-load: 249: sudo: not foundMy earlier solution was:
if test -n "which sudo"; then
sudo=which sudo
fiThis was corrected by Gilles to
Quoted 10 lines
Quoted 5 lines
if test -n "
which sudo 2>/dev/null"; then
sudo=which sudo
elif test -n "type -t sudo 2>/dev/null"; then
sudo=sudo
fiUnfortunately my busybox version 1.1.3 behaves like this:
Quoted 3 lines
~ $ type -t sudo 2>/dev/null
-t: not found
sudo: not found
Quoted 5 lines
What about:
if type sudo >
/dev/null2>&1; then
sudo=sudo
fi
Works fine for me under bash and busybox.
Thanks
Signature · 1 line
Niklaus Giger