Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fork perl only once if displaying a mad file #3

Merged
merged 1 commit into from

2 participants

@raszi

so it will run faster

@tj
Owner
tj commented

nice :D

@tj tj merged commit d89394f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2012
  1. @raszi

    fork perl only once

    raszi authored
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 9 deletions.
  1. +10 −9 bin/mad
View
19 bin/mad
@@ -33,14 +33,15 @@ display() {
display_file() {
cat $1 \
- | perl -pe 's|^#+ *(.+)|\e[1m\1\e[0m|g' \
- | perl -pe 's|`(.+?)`|\e[90m\1\e[0m|g' \
- | perl -pe 's|\*\*(.+?)\*\*|\e[1m\1\e[0m|g' \
- | perl -pe 's|__(.+?)__|\e[1m\1\e[0m|g' \
- | perl -pe 's|\*(.+?)\*|\e[4m\1\e[0m|g' \
- | perl -pe 's|_(.+?)_|\e[4m\1\e[0m|g' \
- | perl -pe 's| (.+)| \e[90m\1\e[0m|g' \
- | perl -pe 's|^| |' \
+ | perl -pe '
+ s|^#+ *(.+)|\e[1m\1\e[0m|g; \
+ s|`(.+?)`|\e[90m\1\e[0m|g; \
+ s|\*\*(.+?)\*\*|\e[1m\1\e[0m|g; \
+ s|__(.+?)__|\e[1m\1\e[0m|g; \
+ s|\*(.+?)\*|\e[4m\1\e[0m|g; \
+ s|_(.+?)_|\e[4m\1\e[0m|g; \
+ s| (.+)| \e[90m\1\e[0m|g; \
+ s|^| |;' \
| less -R
exit
}
@@ -92,4 +93,4 @@ case $1 in
*)
display $1
;;
-esac
+esac
Something went wrong with that request. Please try again.