[RFC] Future of "messages" targets

Nicolas Goutte nicolasg at snafu.de
Fri Sep 16 11:25:34 BST 2005


On Friday 16 September 2005 11:20, Alejandro Exojo wrote:
> 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.

Yes, "type -t" seems to be a good idea for what I have wanted to do.

>
> > > >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.

Thank you! (I have jut takedn the time to test too.)

>
> > 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?

No, I meant just after the sourcing. 

But if you can redefine a function, it is less difficult. Just the first 
function needs to fail. If it is re-defined, it is not failing anymore.

And the "type -t" solution seems even better, as a function can be "unset" 
too.

>
> Greetings.

Have a nice day!





More information about the kde-core-devel mailing list