merge_config.sh: improve indentation
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 13 Mar 2015 06:21:41 +0000 (15:21 +0900)
committerMichal Marek <mmarek@suse.cz>
Tue, 24 Mar 2015 15:48:44 +0000 (16:48 +0100)
It is true that we do not want to move the code too far to the
right, but something like below is not preferred:

    if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
    echo Value of $CFG is redefined by fragment $MERGE_FILE:
    echo Previous  value: $PREV_VAL
    echo New value:       $NEW_VAL
    echo
    elif [ "$WARNREDUN" = "true" ]; then
    echo Value of $CFG is redundant by fragment $MERGE_FILE:
    fi

To fix this, call "continue" if the "grep" command fails to find the
given CONFIG.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/kconfig/merge_config.sh

index 88d89b2986dbe33763aed78c444e1f0bfbf8b165..56584b107bf819d598f57632739191d2b517eb63 100755 (executable)
@@ -103,20 +103,18 @@ for MERGE_FILE in $MERGE_LIST ; do
        CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
 
        for CFG in $CFG_LIST ; do
-               grep -q -w $CFG $TMP_FILE
-               if [ $? -eq 0 ] ; then
-                       PREV_VAL=$(grep -w $CFG $TMP_FILE)
-                       NEW_VAL=$(grep -w $CFG $MERGE_FILE)
-                       if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+               grep -q -w $CFG $TMP_FILE || continue
+               PREV_VAL=$(grep -w $CFG $TMP_FILE)
+               NEW_VAL=$(grep -w $CFG $MERGE_FILE)
+               if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
                        echo Value of $CFG is redefined by fragment $MERGE_FILE:
                        echo Previous  value: $PREV_VAL
                        echo New value:       $NEW_VAL
                        echo
-                       elif [ "$WARNREDUN" = "true" ]; then
+               elif [ "$WARNREDUN" = "true" ]; then
                        echo Value of $CFG is redundant by fragment $MERGE_FILE:
-                       fi
-                       sed -i "/$CFG[ =]/d" $TMP_FILE
                fi
+               sed -i "/$CFG[ =]/d" $TMP_FILE
        done
        cat $MERGE_FILE >> $TMP_FILE
 done