0

My own bash script searches compilation logs (higher-level logs generated by Bitbake cooker while cross-building a Linux software package) for compilation command line strings. Those command strings in searched logs are huge in length, more than 2300 columns of ascii text (due several -I's and -W's). Log file is searched for compilation command line strings using following regex

grep -E -e "^${TARGETCANONICAL}${COMPCMDPATT}"

where

TARGETCANONICAL='arm-oe-linux-gnueabi-'
COMPCMDPATT="gcc[[:space:]].+[[:space:]]-c[[:space:]].+\w+\.c$"

Used grep command is constructed to print out each line matching given pattern, with no manipulation of matching input line printed to grep output. Ubuntu is build machine.

Each compilation command string in log-file includes at few points sequences of multiple subsequent spaces (blanks). For instance:

-ftree-vectorize   -Wno-error=maybe-uninitialized

In lines printed out by grep (regex matches) all those original sequences of blanks are consolidated to one single blank, whitespace. That consolidation of whitespaces is not what was expected here.

What might be the possible reason?

Update: grep output goes to command substitution (bash expansion) whose output is assigned to variable. Then it is printed out using echo or used in compound conditional command - which is the level where myself conducts observations/debugging. Possibly rootcause of observed phenomenon is located even in subsequent command expansion or in assignment.

  • Your grep command should only be matching one line and it should not be modifying that line. Is your output coming directly from grep, or is it being stored in a variable or piped to another filter? – UncleCarl Aug 01 '18 at 17:22
  • Yes, that's my intention not to modify matching lines. Q was updated with more details regarding grep command call context. –  Aug 01 '18 at 17:24
  • Showing us the actual command would be preferable, but if you echo $variable, you need to put double quotes around the variable: echo "$variable". – UncleCarl Aug 01 '18 at 17:38
  • Yes, it was missing quote in grep output postprocessing. –  Aug 02 '18 at 12:29

0 Answers0