From ef86f6e9a29a631c7df62dd55fd5edbdfab53d55 Mon Sep 17 00:00:00 2001 From: SBeans Date: Wed, 28 Nov 2012 10:46:51 +0000 Subject: Fixed -l (showing more than 5 results) and -r (not displaying text of deleted line). --- blasource.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/blasource.php b/blasource.php index f634584..5cc8793 100644 --- a/blasource.php +++ b/blasource.php @@ -9,8 +9,9 @@ // 0.1.1 Fixed -l option for listing for sources. // 0.1.2 Checked -l page number to see if there are any results. // 0.2.0 Fixed -l so it shows 5 results. Added -c Count added -r remove and updated help + // 0.2.1 Fixed -l (showing too many results) and -r (Not showing text of removed line - $version = "BlaSource Version: 0.2.0"; + $version = "BlaSource Version: 0.2.1"; // get the input $stdin = read_stdin(); @@ -46,7 +47,7 @@ exec("echo $line >> blatemp.txt"); $lineNo++; } - else + else if ($line != "") { $stringRemove = $line; $lineNo++; @@ -56,11 +57,11 @@ echo "Removed line " . $lineToRemove . ": " . $stringRemove. "."; break; case "-l": - $last = str_replace(":", "",exec("grep -n \"\" blasource.txt | tail -n 1")) / 5; - $look = 0; + $last = str_replace(":", "",exec("grep -n \"\" blasource.txt | tail -n 1")) / 5 + 1; + $page = 0; if(!isset($stdin[$i+1])) { - $look = 1; + $page = 1; } else { @@ -72,14 +73,14 @@ } else { - $look = $stdin[$i+1]; + $page = $stdin[$i+1]; $i++; } } - $X = ($look*5)-5; - for($j=0;$j<6;$j++) + $X = ($page*5)-5; + for($j=1;$j<6;$j++) { $bla = $j+$X; $temp = exec("grep -n \"\" blasource.txt | head -n" . $bla . " | tail -n1") . " "; -- cgit v1.2.3