List Info

Thread: Is there something grep like in make besides the findstring function?




Is there something grep like in make besides the findstring function?
user name
2007-06-20 18:26:10
I'm trying to check to see if an application is installed in the rules section of a target.

In my case, I'm checking for doxygen.

But I'm currently having issues doing this using findstring.

When using findstring, it seems as though the whole string has to match before it will consider it a match.

The only problem is that the string I'm searching on is "command not found";. But depending on the shell you run it in, the stuff before command not found might look like:

bash: doxygen: command not found

or

sh: doxygen: command not found

Is there any easier way of accomplishing my end goal?

Thanks,
Randy


Re: Is there something grep like in make besides the findstringfunction?
country flaguser name
United States
2007-06-20 18:42:33
Randy Kao wrote:

> bash: doxygen: command not found
> 
> or
> 
> sh: doxygen: command not found
> 
> Is there any easier way of accomplishing my end goal?

Searching for an error string is always a bad idea.  What if
the user
has their locale set to display errors in German?  You'd go
crazy trying
to search for all the different ways of saying "command
not found" in
every shell and every language.

It's not necessary either as the shell gives you a status
value when a
command fails to execute a command, which you can test e.g.

foo := $(shell doxygen --version >/dev/null 2>&1
&& echo "yes")

...will result in foo being "yes" if the command
was successful
otherwise blank.  If you want yes/no then you can do
something like:

foo := $(shell if cmd; then echo yes; else echo no; fi)

Brian


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: Is there something grep like in make besides the findstringfunction?
user name
2007-06-20 18:57:11
Good points Brian. Thanks for the feedback.

I will definitely go your suggested route.

Thanks again.
-Randy

On 6/20/07, Brian Dessent < briandessent.net">briandessent.net> wrote:
Randy Kao wrote:

> bash: doxygen: command not found
>
> or
>
&gt; sh: doxygen: command not found
>
> Is there any easier way of accomplishing my end goal?

Searching for an error string is always a bad idea. ; What if the user
has their locale set to display errors in German?&nbsp; You'd go crazy trying
to search for all the different ways of saying "command not found"; in
every shell and every language.

It's not necessary either as the shell gives you a status value when a
command fails to execute a command, which you can test e.g.

foo := $(shell doxygen --version >/dev/null 2>&1 && echo "yes&quot;)

...will result in foo being "yes&quot; if the command was successful
otherwise blank.&nbsp; If you want yes/no then you can do something like:

foo := $(shell if cmd; then echo yes; else echo no; fi)

Brian

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )