From mboxrd@z Thu Jan 1 00:00:00 1970 From: Masahiro Yamada Date: Fri, 18 Oct 2013 15:37:57 +0900 Subject: [U-Boot] [PATCH 3/3] MAKEALL: fix boards_by_field function In-Reply-To: <20131017134156.79f6df95@lilith> References: <20131017193230.7ED4.AA925319@jp.panasonic.com> <20131017134156.79f6df95@lilith> Message-ID: <20131018153757.7F01.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Albert. > The way the code is written now, board_by_field() has to do the job of > board_by_cpu() and has to know the CPU field has colon-separated > subfields. What should be done is, board_by_field should not even worry > about colons at all, and it is board_by_cpu() which should know about > CPU dubfields and treat them properly. > > Is this clearer? OK. It's clear now. I re-wrote like follows: boards_by_field() { field=$1 regexp=$2 awk '($1 !~ /^#/ && $'"$field"' ~ /^'"$regexp"'$/) { print $7 }' \ boards.cfg } boards_by_arch() { boards_by_field 2 "$@" ; } boards_by_cpu() { boards_by_field 3 "$@" ; boards_by_field 3 "$@:.*" ; } boards_by_soc() { boards_by_field 4 "$@" ; } Is this good enough? BTW, I think these function names are misleading. We want to get the 7th field (Target), not 6th field (Board Name) of boards.cfg by these functions. So I think we should rename s/boards_by_field/targets_by_field/ s/boards_by_arch/targets_by_arch/ s/boards_by_cpu/targets_by_cpu/ s/boards_by_soc/targets_by_soc/ Best Regards Masahiro Yamada