diff options
Diffstat (limited to '')
-rw-r--r-- | build/latex/academia/.envrc | 2 | ||||
-rw-r--r-- | build/latex/academia/init | 19 | ||||
-rw-r--r-- | build/latex/letter/.envrc | 2 | ||||
-rw-r--r-- | build/latex/letter/init | 19 | ||||
-rw-r--r-- | build/latex/presentation/.envrc | 2 | ||||
-rw-r--r-- | build/latex/presentation/init | 19 |
6 files changed, 60 insertions, 3 deletions
diff --git a/build/latex/academia/.envrc b/build/latex/academia/.envrc index 3bc1085..3db39e6 100644 --- a/build/latex/academia/.envrc +++ b/build/latex/academia/.envrc @@ -1,3 +1,5 @@ +#!/usr/bin/env sh + use flake || use nix watch_file flake.nix diff --git a/build/latex/academia/init b/build/latex/academia/init index e8f72c8..b645441 100644 --- a/build/latex/academia/init +++ b/build/latex/academia/init @@ -30,6 +30,16 @@ die() { printf "init: ERROR: %s\n" "$1" exit 1 } +quotify() { + python -c " +import sys +if len(sys.argv) > 1: + text =''.join(sys.argv[1:]) +else: + text = sys.stdin.read() +quoted_text = text.replace(\"'\", \"'\\\\''\") +print(f\"'{quoted_text}'\", end='')" "$@" +} # Prompt the user for a specific variable. # ## Args: @@ -57,7 +67,7 @@ prompt() { LE "> " 0 " " "$pr_suggested_answer" "" fi - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" + pr_new_variable="$(printf '%s=%s' "$pr_variable_upper" "$(quotify "$REPLY")")" eval "$pr_new_variable" printf "%s\n" "$pr_new_variable" >>"$replacement_file" @@ -73,6 +83,8 @@ require mv require sed require chmod +require python + # necessary meta data prompt APPLICATION_NAME "The name of the application" "$(basename "$PWD")" prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')" @@ -169,6 +181,11 @@ while read -r var; do done done <"$replacement_file" +if [ "$(rg "%INIT_" --files-with-matches | wc -l)" -ne 0 ]; then + echo "Following init variables were not replaced. This is a bug." + rg "%INIT_" +fi + # HACK: Re-add the executable permissions to files, which the nix template has somehow # removed <2024-04-02> chmod +x scripts/* diff --git a/build/latex/letter/.envrc b/build/latex/letter/.envrc index 3bc1085..3db39e6 100644 --- a/build/latex/letter/.envrc +++ b/build/latex/letter/.envrc @@ -1,3 +1,5 @@ +#!/usr/bin/env sh + use flake || use nix watch_file flake.nix diff --git a/build/latex/letter/init b/build/latex/letter/init index e8f72c8..b645441 100644 --- a/build/latex/letter/init +++ b/build/latex/letter/init @@ -30,6 +30,16 @@ die() { printf "init: ERROR: %s\n" "$1" exit 1 } +quotify() { + python -c " +import sys +if len(sys.argv) > 1: + text =''.join(sys.argv[1:]) +else: + text = sys.stdin.read() +quoted_text = text.replace(\"'\", \"'\\\\''\") +print(f\"'{quoted_text}'\", end='')" "$@" +} # Prompt the user for a specific variable. # ## Args: @@ -57,7 +67,7 @@ prompt() { LE "> " 0 " " "$pr_suggested_answer" "" fi - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" + pr_new_variable="$(printf '%s=%s' "$pr_variable_upper" "$(quotify "$REPLY")")" eval "$pr_new_variable" printf "%s\n" "$pr_new_variable" >>"$replacement_file" @@ -73,6 +83,8 @@ require mv require sed require chmod +require python + # necessary meta data prompt APPLICATION_NAME "The name of the application" "$(basename "$PWD")" prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')" @@ -169,6 +181,11 @@ while read -r var; do done done <"$replacement_file" +if [ "$(rg "%INIT_" --files-with-matches | wc -l)" -ne 0 ]; then + echo "Following init variables were not replaced. This is a bug." + rg "%INIT_" +fi + # HACK: Re-add the executable permissions to files, which the nix template has somehow # removed <2024-04-02> chmod +x scripts/* diff --git a/build/latex/presentation/.envrc b/build/latex/presentation/.envrc index 3bc1085..3db39e6 100644 --- a/build/latex/presentation/.envrc +++ b/build/latex/presentation/.envrc @@ -1,3 +1,5 @@ +#!/usr/bin/env sh + use flake || use nix watch_file flake.nix diff --git a/build/latex/presentation/init b/build/latex/presentation/init index e8f72c8..b645441 100644 --- a/build/latex/presentation/init +++ b/build/latex/presentation/init @@ -30,6 +30,16 @@ die() { printf "init: ERROR: %s\n" "$1" exit 1 } +quotify() { + python -c " +import sys +if len(sys.argv) > 1: + text =''.join(sys.argv[1:]) +else: + text = sys.stdin.read() +quoted_text = text.replace(\"'\", \"'\\\\''\") +print(f\"'{quoted_text}'\", end='')" "$@" +} # Prompt the user for a specific variable. # ## Args: @@ -57,7 +67,7 @@ prompt() { LE "> " 0 " " "$pr_suggested_answer" "" fi - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" + pr_new_variable="$(printf '%s=%s' "$pr_variable_upper" "$(quotify "$REPLY")")" eval "$pr_new_variable" printf "%s\n" "$pr_new_variable" >>"$replacement_file" @@ -73,6 +83,8 @@ require mv require sed require chmod +require python + # necessary meta data prompt APPLICATION_NAME "The name of the application" "$(basename "$PWD")" prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')" @@ -169,6 +181,11 @@ while read -r var; do done done <"$replacement_file" +if [ "$(rg "%INIT_" --files-with-matches | wc -l)" -ne 0 ]; then + echo "Following init variables were not replaced. This is a bug." + rg "%INIT_" +fi + # HACK: Re-add the executable permissions to files, which the nix template has somehow # removed <2024-04-02> chmod +x scripts/* |