Re: %install section script problem...

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

 



Greg Allen wrote:
> Here's the snippet of code from "func":
>  
>     cat $file | egrep -v '^#' |  \

You have nominated yourself for a "useless use of cat" award.  You
don't need it here.  Just pass it to grep directly.

    egrep -v '^#' $file |  \

But wait.  You are not using egrep functionality.  So just use grep.

    grep -v '^#' $file |  \

But wait.  The return code of grep depends on whether it matched or
not.  Since rpm scripts usually run with 'sh -e' you want to avoid
using grep.  Use sed instead.  Then the return code is always whether
it had a problem or not and not whether it matched something or not.

    sed '/^#/d' $file |  \

>     while read -a line; do

read -a is, of course, nonportable

>         echo ${line[$platform_idx]} | egrep $egrep_flags "^$platform$|^$platform,|,$platform,|,$platform$"

The grep there is fine since you desire the return code to be whether
it matched or not.

>         if [ $? -eq 0 ]; then
>            # Do some stuff here.
>         fi
>     done    
>     # Check if file processing succeeded.
>     if [ $? -ne 0 ]; then
>         return 1111

This can only mean the read -a failed if you are here.  Note that 1111
is out of the valid range of 0-255.

>     fi

Bob


_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux