[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Quick Bash question



On Fri, 3 Jan 2003, Colin Watson wrote:

> On Fri, Jan 03, 2003 at 12:22:14AM -0800, Bill Moseley wrote:
> > In a shell script does:
> > 
> >   MODPROBE=:
> > 
> > do anything special besides set $MODPROBE to ":"?
> 
> No.
> 
> >     MODPROBE=:
> [...]
> >             debug_mesg Looking for module $MODULE with modprobe=$MODPROBE
> >             if $MODPROBE -n $MODULE >/dev/null 2>&1 &&
> >                     ! $MODPROBE $MODULE >/dev/null 2>&1 ; then
> 
> ':' is another name for 'true', which ignores all its arguments and
> returns true. It's often used as a substitute for a program that wasn't
> found on the build system or as a way to temporarily disable something.
> Since 'true && ! true' is false, that's why you're seeing this
> behaviour.
> 
> It's possible that it's intentional; I don't know. If you have a
> problem, it's probably best to file a bug.

Ok.  In the above script, in this case, $MODULE is suppose to be the name
of a program or script to run.  As far as I can tell (by trying it) the
script is never run.

In other words, from what I can see it seems as if the program "foo" is
not run, although it it claims "ran foo".

    if : -n foo >/dev/null 2>&1 && ! : foo >/dev/null 2&1> ; then
       echo "failed to load"
    else
       echo "ran foo"
    fi


the intention is to run "foo", so it looks like a bug.

Of course, what started all this was someone claiming to use this method
to run a script on a hotplug event.  Perhaps they have a different version
of the script.

Thanks for the help.



-- 
Bill Moseley moseley@hank.org



Reply to: