diff --git a/.config/shell/bin/pandoc-make b/.config/shell/bin/pandoc-make index bbdc222..c63f0ab 100755 --- a/.config/shell/bin/pandoc-make +++ b/.config/shell/bin/pandoc-make @@ -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