Hi,
I've got an array that contains a list of object file names called OBJCUCUBLE. I'm trying use this to create symbolic links to the source files that correspond to these object files.
The script I have works fine except when there is a space in the file name. Could you please have a look at what I have and point me in the direction of where I'm going wrong?
Thanks for your help
M
Trainee Chocolate Management Executive.
I've got an array that contains a list of object file names called OBJCUCUBLE. I'm trying use this to create symbolic links to the source files that correspond to these object files.
The script I have works fine except when there is a space in the file name. Could you please have a look at what I have and point me in the direction of where I'm going wrong?
Code:
hold=;
for obj in ${OBJCUCIBLE}; do
# if the listed item doesn't end ".o"
if [ ! -n "$( echo ${obj} | grep '[.]o')" ]; then
[ ${ioptv} -gt 1 ] && echo "ERROR - The file name <$obj> is incomplete."
hold=$obj
else
# if we have a value in hold stick it together with
# the new value with an escaped space
if [ -n "$hold" ]; then
obj="${hold}\ ${obj}"
hold=;
fi
#
# Now work out which source file matches the object name
cd ${CD}
fn=`echo $obj | sed 's/[.]o[ ]*$//' | sed 's:^.*[/]::'`
# check for all recognised source file extensions
src=`ls $fn.[cCfsly] 2>/dev/null | awk ' { print $1 } ' `
if [ -n "${src}" ] ; then
cd ${TARGET}
rm -f ./${src}
ln -s ../${src} .
else
echo "An error has occurred because the file <${obj}> can't be found"
fi
fi
done
Thanks for your help
M
Trainee Chocolate Management Executive.