[RFC] Future of "messages" targets

Alejandro Exojo suy at kurly.org
Fri Sep 16 10:20:34 BST 2005


El Jueves, 15 de Septiembre de 2005 17:15, Nicolas Goutte escribió:
> On Thursday 15 September 2005 17:07, Thiago Macieira wrote:
> > Nicolas Goutte wrote:
> > >And how do you check that there was a "mv" declared as function.

Maybe the "type" builtin can help.

foo ()
{
echo "foo"
}

FOOTYPE=`type -t foo`

if [ $FOOTYPE == 'function' ]
then
        echo "do something"
else
        echo "do something else"
fi

"type -t" seems a bashism, but without options should be portable, and its 
output is similar.

> > >Sure, defines are run before any outside executable or cript. But here
> > > we have no guarantee that the function was defined and that is the
> > > problem.
> >
> > Why would you want to depend on a function you didn't declare and aren't
> > sure to be there? If you want it, simply declare it.
>
> Stephan Kulow wants to source (not excute) the script. I am not sure that
> Bash can handle two defintions of the same function. (I have not tested.)

Yes, acts the same as if it is a variable or alias: the first value is 
discarded, and the second is used.

> And it cannot be guaranteed that the function will be defined, as there
> could be an error in the script, the same as there are currently errors in
> some "messages" targets.
>
> So we need to be able to catch such errors. We do not need more than an
> error message, but we need to create that error message.

Do you mean an error when sourcing the file with the functions? set -e, maybe?

Greetings.

-- 
Alex (a.k.a. suy) - GPG ID 0x0B8B0BC2
http://darkshines.net/ - Jabber ID: suy at bulmalug.net




More information about the kde-core-devel mailing list