removing bash/gawk'isms from wineshelllink

Vitaliy Margolen wine-devel at kievinfo.com
Thu Apr 26 08:08:26 CDT 2007


Ben Taylor wrote:
> I'm still working on the script to make it more "sh" compatible, 
> but I think I have a potential fix for the line that reads:
> 
>         for i in $(get_menu_entries "$1"); do
> 
> and replace it with
> 
>          for i in `get_menu_entries "$1"`; do

What is the problem with this particular part? What shell are you using
that doesn't understand $() command expansion? Even the basic BSD "sh"
does support this. However this doesn't really affect anything, and
should work in all shells too.

> The problem with the get_menu_entries function is that the awk
> uses the match function, which is only available in gawk and nawk,
> and julliard didn't like my idea of making the script just use gawk or
> nawk, so I have to rewrite the function to look like this:
> 
> get_menu_entries()
> {
>    tmp="$xdg_config_dir/$1.menu"
> 
>    if [ -r "$tmp" ] ; then
>         awk '
> BEGIN {  RS="<" }
> /^Filename/ {
>   RSTART=index($0,">");
>   if (RSTART > 0) {
>      print substr($0,RSTART+1)
>   }
> }' $tmp
> 

This looks reasonable to me. Wine uses match() to find a matching ">" so
 index() would do just fine.

Vitaliy.



More information about the wine-devel mailing list