Output errors to stderr
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 19 Apr 2008 09:03:38 +0000 (09:03 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 19 Apr 2008 09:03:38 +0000 (09:03 +0000)
Only search currency symbol on the begining of currencies lines

curcy

diff --git a/curcy b/curcy
index b7ae11b832a38f851aa9b520321586a997d37b09..8c36d2b4333be4ba2d0cc9a1bc2c1d4609c4bba1 100755 (executable)
--- a/curcy
+++ b/curcy
@@ -3,27 +3,27 @@
 set -e
 
 if [ -z "$1" ]; then
-    echo "You must give an international currency code as a parameter, such as USD"
+    echo "You must give an international currency code as a parameter, such as USD" >&2
     exit 1
 fi
 
 local_currency=`locale int_curr_symbol`
 if [ -z "$local_currency" ]; then
-    echo "Can't find you locale currency code"
+    echo "Can't find you locale currency code" >&2
     exit 1
 fi
 
-local_currency_value=`grep $local_currency /var/currencies | cut -d \  -f 2`
+local_currency_value=`grep ^$local_currency /var/currencies | cut -d \  -f 2`
 if [ -z "$local_currency_value" ]; then
-    echo "You currency $local_currency is unavailable in exchange rate database"
+    echo "You currency $local_currency is unavailable in exchange rate database" >&2
     exit 1
 fi
 #echo "1 euro = $local_currency_value $local_currency"
 
 target_currency=$1
-target_currency_value=`grep -e $target_currency /var/currencies | cut -d \  -f 2`
+target_currency_value=`grep ^$target_currency /var/currencies | cut -d \  -f 2`
 if [ -z "$target_currency_value" ]; then
-    echo "The currency $target_currency is unavailable in exchange rate database"
+    echo "The currency $target_currency is unavailable in exchange rate database" >&2
     exit 1
 fi
 #echo "1 euro = $target_currency_value $target_currency"