#!/bin/bash ignore=" cs20202 cs20204 cs20215 " headercontent=" #ifndef %s_h_ #define %s_h_ #include <common.h> char *%s_name(); void %s_game(); #endif " srccontent=" #include <%s.h> #include <stdlib.h> static char name[] = \"%s\"; void %s_game() { addstr(\"%s\"); getch(); } char *%s_name() { return name; } " makecontent=" CC = gcc CFLAGS = -I. -I.. CLIBS = -lncurses TARGET = lib%s.a OBJS = %s.o \$(TARGET): \$(OBJS) \tar rcs \$(TARGET) \$^ clean: \trm -f \$(TARGET) \$(OBJS) " for student in cs202{00..21}; do s=$(echo "$ignore" | grep "$student") if ! [[ -z $(echo "$ignore" | grep "$student") ]]; then continue fi dir="$student" srcfile="$student.c" headerfile="$student.h" mkdir -p "$dir" headerout=$(echo "$headercontent" | sed "s/%s/$student/g") srcout=$(echo "$srccontent" | sed "s/%s/$student/g") makeout=$(echo "$makecontent" | sed "s/%s/$student/g") echo "$headerout" > "$dir/$headerfile" echo "$srcout" > "$dir/$srcfile" echo -e "$makeout" > "$dir/Makefile" done