diff --git a/build.sh b/build.sh index a00318b..dc42896 100755 --- a/build.sh +++ b/build.sh @@ -53,6 +53,9 @@ read_metadata() { } convert_to_array() { + local meta_key + local meta_value + # Converts the metadata into two arrays: one with the key, and the other with the value. readarray -t meta_key < <(echo -e "$1" | awk -F: '{print $1}') readarray -t meta_value < <(echo -e "$1" | awk -F: '{st = index($0,":"); values = substr($0,st+1); print values}' | cut -c 2-) @@ -118,7 +121,7 @@ replace_vars() { md_to_html() { # Convert .md files from 'source' and place them into the correct locations into 'output' - files=$(find "$BASE_PATH/source" -name "*.md") + local files=$(find "$BASE_PATH/source" -name "*.md") for file in $files; do read_metadata "$file" # Sets the 'metadata' variable @@ -132,7 +135,7 @@ md_to_html() { sed -i "1,${num_lines}d" "$BASE_PATH/temp/$(basename "$file")" # Construct path for output file - path_for_output=$(realpath --relative-to="${BASE_PATH}/source" "$file") + local path_for_output=$(realpath --relative-to="${BASE_PATH}/source" "$file") path_for_output="${BASE_PATH}/output/${path_for_output}" path_for_output="$(dirname $path_for_output)/$(basename $path_for_output .md).html" @@ -149,7 +152,7 @@ md_to_html() { gen_sorted_file_list() { # Generate a list of the HTMl files, sorted by when they were last modified (read from the contents of the HTML file) - files=$(find "$BASE_PATH/output" -name "*.html") + local files=$(find "$BASE_PATH/output" -name "*.html") local date_mod for file in $files; do @@ -179,19 +182,19 @@ gen_sorted_file_list() { # Generate a list of the HTMl files, sorted by when the gen_index_page() { # Generate an index page (site map) that includes links to the other pages - index_file_html="