From 5a5ef628dc4666e03fadcef33392849505bce1a3 Mon Sep 17 00:00:00 2001 From: Emily Frost Date: Tue, 29 Jun 2021 12:11:32 -0500 Subject: [PATCH] Added an error if the output file already exists. --- nyan | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nyan b/nyan index 58b1bfb..ec00310 100755 --- a/nyan +++ b/nyan @@ -43,7 +43,13 @@ if [ -z "$output_file" ]; then exit 1 fi -echo "Concatenating files..." +# TODO: Add overwrite switch. +if [ -e "$output_file" ]; then + echo "Error: Output file exists." + exit 1 +fi + +echo "Preparing to concatenate files." declare -i total_size=0 for fname in "$@"; do if [ ! -e "$fname" ]; then @@ -59,8 +65,7 @@ for fname in "$@"; do fi done -# TODO: Make sure that output_file does not exist. Maybe add an overwrite switch. - +echo "Concatenating files..." if [ $abort -eq 0 ]; then cat "$@" | pv -epts "$total_size" > "$output_file" echo "Done!"