diff options
author | Ben Harris <ben@tilde.team> | 2021-12-01 10:22:00 -0500 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2021-12-01 10:22:00 -0500 |
commit | e2fdc6aee4baf5939266a68938c359bf635f2d05 (patch) | |
tree | dfb5380d6268a3d5b42692234763c4cf370cf13b | |
parent | 57389ae1947c44242cfc25a9c71921cd096738d7 (diff) |
use current date(1) if $1 is missing
-rw-r--r-- | aoc2021/getday.sh | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/aoc2021/getday.sh b/aoc2021/getday.sh index eb7faa0..e9d8d6a 100644 --- a/aoc2021/getday.sh +++ b/aoc2021/getday.sh @@ -5,9 +5,18 @@ if [ -z "$session" ]; then printf "missing session cookie\n" fi + +if [ -z "$1" ]; then + day=$(date +"%e" | xargs) +else + day="$1" +fi -curl -s https://adventofcode.com/2021/day/"$1"/input \ +curl -s https://adventofcode.com/2021/day/"$day"/input \ --cookie "session=$session" \ - -o "$(printf "input/day%02d.in" "$1")" + -o "$(printf "input/day%02d.in" "$day")" -sed "s/XX/$1/g" DayXX.cs.txt > "$(printf "Day%02d.cs" "$1")" +class=$(printf "Day%02d.cs" "$day") +if [ ! -f "$class" ]; then + sed "s/XX/$1/g" DayXX.cs.txt > "$class" +fi |