diff options
author | root <root@jones.dk> | 2009-10-24 15:46:23 +0200 |
---|---|---|
committer | root <root@jones.dk> | 2009-10-24 15:54:29 +0200 |
commit | e3f7693b7ba8ccb030a4044e81872136c4581b82 (patch) | |
tree | 7f4fe953eeabbe27d30aca3bd09206679c6c582f /localmarkdown2sms | |
parent | 9adbf437e2886e01943e658fd7c88819fb321666 (diff) |
Replace first argument with env flag mdpath, add santity check, and unescape ARGV only once.
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-x | localmarkdown2sms | 15 |
1 files changed, 9 insertions, 6 deletions
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 |