From 6bfc7bbcbc5138b5e0ffb6cdb60674c6d7f0ec9f Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 11 Jan 2023 21:57:46 +0100 Subject: [PATCH] zsh:funcs: Write a wrapper for pdfunite Write a wrapper for pdfunite that tries to prevent an overwrite of an existing file when forgetting to specify the destination-file. --- .config/zsh/zshrc.d/40-functions.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 542d153..549c8d4 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -619,3 +619,14 @@ pyhelp() { $py_exec -c "${import_statement}help($arg)" done } + +# A small wrapper that tries to prevent an overwrite of an existing file when +# forgetting to specify the destination-file. +pdfunite() { + if [[ -e "$@[-1]" ]]; then + print >&2 "Destination-file exists already!" + return 2 + fi + + command "$@" +}