From c5dbac0e9c82d27c70b8044e791d0924d96fd792 Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sun, 5 Dec 2021 12:41:14 -0500 Subject: [PATCH] don't run curl if file exists --- new.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/new.sh b/new.sh index d5556cc..f0f4cf7 100755 --- a/new.sh +++ b/new.sh @@ -6,6 +6,10 @@ if [ "${1}" != "" ]; then padded=$(printf "%02g" ${1}) mkdir -p ${padded}/inputs touch ${padded}/inputs/{input,testinput} - curl -s -H "Cookie: session=`cat .cookie`" https://adventofcode.com/${__year}/day/${1##0}/input > "${padded}/inputs/input" - cp -n main.go.tmpl ${padded}/main.go + if [ ! -f "${padded}/inputs/input" ]; then + curl -s -H "Cookie: session=`cat .cookie`" https://adventofcode.com/${__year}/day/${1##0}/input > "${padded}/inputs/input" + fi + if [ ! -f "${padded}/main.go" ]; then + cp -n main.go.tmpl ${padded}/main.go + fi fi