Handle tmpfile in snippet

This commit is contained in:
BarbUk 2019-10-28 15:07:24 +04:00
parent 7181da294b
commit c172cc4e67

4
snippy
View File

@ -137,6 +137,10 @@ run() {
elif grep -qE "^##noparse" "${snippets_directory}/${snippet}"; then elif grep -qE "^##noparse" "${snippets_directory}/${snippet}"; then
content="$( tail -n +2 "${snippets_directory}/${snippet}" )" content="$( tail -n +2 "${snippets_directory}/${snippet}" )"
# replace tmpfile for snippets with ##tmpfile header
elif grep -qE "^##tmpfile" "${snippets_directory}/${snippet}"; then
content="$( bashdown_simple <<< "$(tail -n +2 "${snippets_directory}/${snippet}" | sed "s%\$tmpfile%$tmpfile%g" )" )"
# execute bash script in scripts dir # execute bash script in scripts dir
elif [[ $(dirname "${snippet}") == 'scripts' ]] && grep -qE "^#!/bin/bash" "${snippets_directory}/${snippet}"; then elif [[ $(dirname "${snippet}") == 'scripts' ]] && grep -qE "^#!/bin/bash" "${snippets_directory}/${snippet}"; then
content="$( bash "${snippets_directory}/${snippet}" )" content="$( bash "${snippets_directory}/${snippet}" )"