Permalink
Browse files

Merge pull request #3 from raszi/master

fork perl only once if displaying a mad file
  • Loading branch information...
2 parents 477858e + 0587f07 commit d89394fa476807128e05ce58e53746f030b1eaf6 TJ Holowaychuk committed Apr 16, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 bin/mad
View
@@ -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

0 comments on commit d89394f

Please sign in to comment.