Permalink
Browse files

fork perl only once

  • Loading branch information...
1 parent 477858e commit 0587f078fec2189a5965c1700e5ef9d6a5f27cb1 @raszi raszi 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 0587f07

Please sign in to comment.