So the script can do either depending on if you set the variable "METHOD" to either wrap or link. I think I might want a third option where it will export the environmental variables if they aren't already set.
Anyway, I really don't know if any of this is a good Idea but here is my script
Code: Select all
#!/bin/bash
export SUFF='-63'
export METHOD='wrap'
read -r -d '' HDR <<'EOF'
#!/bin/bash
#CPATH=
export C_INCLUDE_PATH='/usr/libgcc63/gcc/i486-slitaz-linux/6.3.0/include'
export CPLUS_INCLUDE_PATH='/usr/include/c++/6.3.0'
#OBJC_INCLUDE_PATH
EOF
echo "HDR=$HDR"
D='$' #I can't get the dollar sign end of line terminator to work with sed no matter what I do!
for line in `cat /var/lib/tazpkg/installed/gcc63/files.list`; do #'/usr/bin/c++-63'; do #
read -r -d '' SED_EXP <<EOF
s/^\(.*\)\($SUFF\)/a='\1'; b='\2'/p
EOF
echo "SED_EXP=$SED_EXP"
export SED_EXP #Not sure if this is necessary
echo "line=$line"
export line #Not sure if this is necessary
echo "$line2"
EXP=$( echo "$line" | sed -n "$SED_EXP")
echo "EXP=$EXP"
eval "$EXP"
if [ -n "$b" ]; then
DNAME="$( dirname $a)"; echo "DNAME=$DNAME"
cd "$DNAME"
LNAME="$( basename $a )"
echo "LNAME=$LNAME"
ONAME="$LNAME"-63
echo "ONAME=$ONAME";
case $METHOD in
'wrap')
echo "$HDR" > "$LNAME"; echo "$ONAME "'$@'>>"$LNAME"; chmod 773 "$LNAME"; ;;
'link')
ln -s "$ONAME" "$LNAME"; ;;
esac
#exit
fi
done
The biggest headache was getting sed to do the write thing, and I still can't get the '$' symbol to match the end of the line, so I guess this is a potential bug in my script. Fortunately none of the paths I'm applying it to have -63 in the middle so the bug hasn't caused me problems yet.
I'm thinking that I'll try it with perl instead of sed due to not being able to match the end of the line with sed.