Quote:
Originally posted by nguyenzoro
Hi everyone,
I have a function that return the value of a key in resource file
EX : MSG001=Message 1
This function will return "Message 1" when called by
message=`getProperty filename MSG001`
But when I'd like to use the result of this function, I got the the following error:
When I echo the result, it is like:
echo $message
I got : $'Message 1\r'
So it will be error when I add this string with another variable
value="message is $message"
output is : message is
What is the problem? Please help me.
getProperty() {
if [ $# -lt 2 ] ; then
echo "$USAGE" ;
exit 1 ;
fi
while read LINE
do
case $LINE in
$2*) replace="$2=";
# replace msgID and = with ""
# ex : replace "MSG0001=" with ""
sbstr=${LINE/"$replace"/""} ;
echo "$sbstr";
break ;;
esac
done < $1
}
|
Sorry,
I mean that after processing this line :
message=`getProperty filename MSG001`
this variable : message has the value :
message=$'Message 1\r'
and when I use this variable to add with another variable, it is not right
for ex :
log_prefix="test"
logfile="$message/$log_prefix"
It was not like : logfile="Message 1/test"
It became : logfile="Message 1\r/test"
So when I created the file with this name, it caused the problem.
Thanks.