From 103cd6deb3870ea2750c14b78b6ce5fb27ec61c5 Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Wed, 21 Jan 2015 23:36:05 +0200 Subject: [PATCH] Check if argument is a file --- parsedown | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/parsedown b/parsedown index bbb1cde..156d1c2 100755 --- a/parsedown +++ b/parsedown @@ -6,9 +6,14 @@ require(dirname(__FILE__).'/Parsedown.php'); // From a file if (isset($argv[1])) { + if ( ! is_file($argv[1])) { + printf('"%s" is not a file', $argv[1]); + exit(1); + } + if ( ! is_readable($argv[1])) { printf('Count not read "%s"', $argv[1]); - exit(1); + exit(2); } $markdown = file_get_contents($argv[1]);