From e3f7693b7ba8ccb030a4044e81872136c4581b82 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 24 Oct 2009 15:46:23 +0200 Subject: Replace first argument with env flag mdpath, add santity check, and unescape ARGV only once. --- localmarkdown2sms | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'localmarkdown2sms') diff --git a/localmarkdown2sms b/localmarkdown2sms index 215f010..be74724 100755 --- a/localmarkdown2sms +++ b/localmarkdown2sms @@ -41,18 +41,16 @@ my $sms_pw = $ENV{SMS_PW} || "foobar"; my $sms_phone = $ENV{SMS_PHONE}; my $sms_smsc = $ENV{SMS_SMSC}; my $sms_msgtag = $ENV{SMS_MSGTAG} || "text"; +my $path = $ENV{mdpath}; my (%file, %delay, %reply); -my ($path) = shift @ARGV; -my ($phone) = shift @ARGV; -my ($key) = lc (shift @ARGV); -# decode data passed from kannel +# decode data if passed from kannel if ($urldecode) { - $phone = uri_unescape($phone); - $key = uri_unescape($phone); @ARGV = uri_unescape(@ARGV); } +my ($phone) = shift @ARGV; +my ($key) = lc (shift @ARGV); # strip international prefix # (prefix is optional some places and illegal at other places - forgot where) @@ -71,6 +69,11 @@ if ($debug) { Log::Log4perl->easy_init($ERROR); } +unless ($path and -f $path) { + ERROR "environment variable \"mdpath\" missing or wrong."; + exit 1; +} + foreach my $file (read_dir( $path )) { my ($key, $i, $skipkeysection, $skipcontent); # suppress repeated warnings for same issue -- cgit v1.2.3