pandoc-make: add error handling for if no files are given
This commit is contained in:
parent
152a960d9c
commit
afdb10e79f
1 changed files with 7 additions and 1 deletions
|
@ -60,12 +60,12 @@ for FILE in "$@";do
|
|||
# Guard against overwriting md files and tex files
|
||||
if { [[ "$OUTPUT_FORMAT" = md ]] || [[ "$OUTPUT_FORMAT" = tex ]]; } && [[ -f "$OUTPUT_FILE" ]]; then
|
||||
if confirm "Overwrite $FILE? [y/N]: "; then
|
||||
|
||||
# Make new file names until there is no overwriting
|
||||
while [[ -f "$OUTPUT_FILE" ]]; do
|
||||
OUTPUT_FILE="${FILE%.*}-$((FILE_NUM++)).${OUTPUT_FORMAT##.}"
|
||||
done
|
||||
echo "Not overwriting, new name: '$OUTPUT_FILE'"
|
||||
|
||||
else
|
||||
# Give some time to ctrl-c before overwrite…
|
||||
SLEEP_DURATION=1
|
||||
|
@ -87,4 +87,10 @@ for FILE in "$@";do
|
|||
fi
|
||||
done
|
||||
|
||||
# Error if no files were processed
|
||||
if [ -z "$OUTPUT_FILE" ]; then
|
||||
echo "Error: no files to process were found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# vim:et ts=3 sw=3
|
||||
|
|
Loading…
Add table
Reference in a new issue