Hi folks,
I am using a shell script to display the referred libraries names of any specified cpp code. Given below is the script:
shell script "grblib"
-------------------------------------------------------------------------
#!/bin/sh
# get the lines having "include" pattern
libMatch=`strMatch $1 "include"`
# check each lines
for x in $libMatch; do
tknFlag=0
libTkn=`echo $x`
# Flag to check .h extension (add new to filter them in)
hExtTknFlag=`echo $x | grep -c "\.h"`
# Common filtering based on pattern
rTknFlag=`echo $x | grep -c ">"`
dTknFlag=`echo $x | grep -c "\$include\""`
hshTknFlag=`echo $x | grep -c "#include <"`
if [ $dTknFlag -eq 1 ]; then
tknFlag=1
libTkn=`echo $libTkn | sed 's/$//g'`
libTkn=`echo $libTkn | sed 's/"//g'`
libTkn=`echo $libTkn | tr -d ";"`
else
if [ $hshTknFlag -eq 1 ] || [ $rTknFlag -eq 1 ] ; then
tknFlag=1
libTkn=`echo $libTkn | sed 's/#//g'`
libTkn=`echo $libTkn | sed 's/<//g'`
libTkn=`echo $libTkn | sed 's/>//g'`
libTkn=`echo $libTkn | sed 's/iolib\///g'`
else
hshTknFlag=`echo $x | grep -c "#include \""`
if [ $hshTknFlag -eq 1 ]; then
libTkn=`echo $libTkn | sed 's/#//g'`
libTkn=`echo $libTkn | sed 's/"//g'`
libTkn=`echo $libTkn | tr -d ";"`
else
tknFlag=0
fi
fi
fi
if [ $hExtTknFlag -eq 1 ]; then
if [ $tknFlag -eq 1 ]; then
# print the final output
echo $libTkn
fi
fi
done
-------------------------------------------------------------------------
The strMatch out puts the following from the sample.cpp file
8: // 08-06-01 JS Replaced include/dri and app with SCCS get sequence
18: #include <string.h> // String manipulation functions
19: #include <iolib/Misc.h> // Miscellaneous functions
20: $include "DriPrm.h"; // Infrastructure parameters
21: $include "DriDef.h"; // Infrastructure definitions
22: $include "GblDef.h"; // DRS global definitions
23: #include "ErrMsg.h"
24: $include "ChipImg.h"; // Chip image declarations
25: #include "MtqHdr.h" // MTQ record header
26: #include "MtqCsm.h"
27: #include "VerDef.h" // VER support functions anddefinitions
------------------------------------------------------------------------
While running the script
$grblib sample.cpp
The output comes normal and correct
string.h
Misc.h
DriPrm.h
DriDef.h
GblDef.h
ErrMsg.h
ChipImg.h
MtqHdr.h
MtqCsm.h
VerDef.h
-------------------------------------------------------------------------
But in the shell the text color after ErrMsg.h is dark grey in color, and when it is redirected to a file say tmpfile, i saw the following...
string.h
Misc.h
DriPrm.h
DriDef.h
GblDef.h
ErrMsg.h^[[0m
ChipImg.h
MtqHdr.h
MtqCsm.h^[[0m
VerDef.h
-------------------------------------------------------------------------
I have no idea from where ^[[0m is coming from....if i am right it may be due to the space after ErrMsg.h (absence of usual comment) that generates this character. Since this script is used by another one that gets the file from the library the "ErrMsg.h^[[0m" is creating trouble since it is supposed to be "ErrMsg.h"
This is the line that writes the list generated from grblib to a file
echo -e `grblib $x | tr " " "\n"` > $libFile"Lib.bas"
Since the output is not displaying ^[[0m but changing the text color alone, i need to get rid of this pattern from the name.
Kindly help.....