Don't write empty $content in tmpfile and return if tmpfile is empty
This commit is contained in:
parent
c172cc4e67
commit
a398357fb1
7
snippy
7
snippy
@ -150,12 +150,19 @@ run() {
|
|||||||
content="$( bashdown_simple < "${snippets_directory}/${snippet}" )"
|
content="$( bashdown_simple < "${snippets_directory}/${snippet}" )"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$content" ]; then
|
||||||
printf "%s" "$content" > "$tmpfile"
|
printf "%s" "$content" > "$tmpfile"
|
||||||
|
fi
|
||||||
|
|
||||||
else [[ ${snippet} =~ ^$ ]]
|
else [[ ${snippet} =~ ^$ ]]
|
||||||
${snippet##*$} 2>/dev/null > "$tmpfile" # execute as bashcommand
|
${snippet##*$} 2>/dev/null > "$tmpfile" # execute as bashcommand
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if tmpfile is empty at this step, nothing to do.
|
||||||
|
if [ ! -s "$tmpfile" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# save current clipboard
|
# save current clipboard
|
||||||
current_clipboard=$(xsel -b)
|
current_clipboard=$(xsel -b)
|
||||||
# replace {clipboard} by the clipboard content
|
# replace {clipboard} by the clipboard content
|
||||||
|
Loading…
Reference in New Issue
Block a user