From 60127de1e3114ed02369218b1725851107b677a8 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 9 Dec 2015 13:50:15 +0000 Subject: [PATCH] Take list of files to edit as args --- scripts/add-matrix-org-stylings.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/add-matrix-org-stylings.sh b/scripts/add-matrix-org-stylings.sh index 9a9256b2..f8edd6ac 100755 --- a/scripts/add-matrix-org-stylings.sh +++ b/scripts/add-matrix-org-stylings.sh @@ -1,26 +1,27 @@ #!/bin/bash -eu -if [[ $# != 1 || ! -d $1 ]]; then - echo >&2 "Usage: $0 include_dir" +if [[ $# == 0 || ! -d $1 ]]; then + echo >&2 "Usage: $0 include_dir file_to_replace..." exit 1 fi -HEADER="$1/head.html" -NAV_BAR="$1/nav.html" -FOOTER="$1/footer.html" +include_dir="$1" +shift -for f in "$1"/{head,nav,footer}.html; do +HEADER="${include_dir}/head.html" +NAV_BAR="${include_dir}/nav.html" +FOOTER="${include_dir}/footer.html" + +for f in "${include_dir}"/{head,nav,footer}.html; do if [[ ! -e "${f}" ]]; then echo >&2 "Need ${f} to exist" exit 1 fi done -files=gen/*.html - perl -MFile::Slurp -pi -e 'BEGIN { $header = read_file("'$HEADER'") } s##$header -#' ${files} +#' "$@" perl -MFile::Slurp -pi -e 'BEGIN { $nav = read_file("'$NAV_BAR'") } s##
@@ -29,7 +30,7 @@ perl -MFile::Slurp -pi -e 'BEGIN { $nav = read_file("'$NAV_BAR'") } s## <
-#' ${files} +#' "$@" perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s##
@@ -41,4 +42,4 @@ perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s## $footer
- #' ${files} + #' "$@"