From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Wed, 1 Aug 2012 18:31:37 -0400 Subject: [U-Boot] [PATCH v4 1/2] tools, config.mk: add binutils-version In-Reply-To: <50083BCD.8020108@ti.com> References: <1342655153-9023-1-git-send-email-amartin@nvidia.com> <201207191243.30305.vapier@gentoo.org> <50083BCD.8020108@ti.com> Message-ID: <201208011831.39578.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thursday 19 July 2012 12:54:37 Tom Rini wrote: > On 07/19/2012 09:43 AM, Mike Frysinger wrote: > > On Thursday 19 July 2012 11:38:39 Tom Rini wrote: > >> On 07/19/2012 08:21 AM, Mike Frysinger wrote: > >>> On Thursday 19 July 2012 11:08:10 Tom Rini wrote: > >>>> On 07/18/2012 08:11 PM, Mike Frysinger wrote: > >>>>> On Wednesday 18 July 2012 19:45:52 Allen Martin wrote: > >>>>>> +MAJOR=$($gas --version | head -1 | awk '{print $NF}' | > >>>>>> cut -d . -f 1) +MINOR=$($gas --version | head -1 | awk > >>>>>> '{print $NF}' | cut -d . -f 2) + +printf "%02d%02d\\n" > >>>>>> $MAJOR $MINOR > >>>>> > >>>>> can be replaced with a single awk script: > >>>>> > >>>>> $gas --version | awk '{ gsub(/[.]/, " ", $NF) $0 = $NF > >>>>> printf "%02d%02d\n", $1, $2 exit }' > >>>> > >>>> That looks much longer and we call this once so a few execs > >>>> is noise. > >>> > >>> here's a shorter version: $gas --version | awk '{ gsub(/[.]/, " > >>> ", $NF); $0 = $NF; printf "%02d%02d\n", $1, $2; exit }' > >> > >> And still over 80 chars before we assign it to a variable. I > >> could get it to 77 chars with all whitespace removed. > > > > which is why i unrolled it to make it readable. i don't know what > > metrics you're using here, but i don't think the awk version is > > "longer" by really any of them. > > The metric of 'wc -c' and "what fits in a single line, unwrapped on an > 80x24 terminal." awk is great and awesome, don't get me wrong, but > it's not doing the job as compactly as the original. obviously i disagree. i find the awk version "better" in just about every way. maybe someone else will jump in with their favorite bike. -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. URL: