#!/bin/bash # Script to create a new C project with JCL and source file # Usage: ./newjob.sh # NAME must be 8 characters or less (MVS member name restriction) set -e if [ $# -ne 1 ]; then echo "Usage: $0 " echo " NAME: 8 characters or less (will be uppercased for MVS)" echo "" echo "Example:" echo " $0 hello" exit 1 fi NAME_INPUT="$1" NAME=$(echo "$NAME_INPUT" | tr '[:lower:]' '[:upper:]') # Validate name length (MVS member names are max 8 characters) if [ ${#NAME} -gt 8 ]; then echo "Error: Name '$NAME' is longer than 8 characters (${#NAME} chars)" echo "MVS member names must be 8 characters or less" exit 1 fi # Validate name format (alphanumeric, must start with letter) if ! [[ "$NAME" =~ ^[A-Z][A-Z0-9]*$ ]]; then echo "Error: Name '$NAME' must start with a letter and contain only letters and numbers" exit 1 fi JCL_FILE="jcl/${NAME}.jcl" SRC_FILE="src/${NAME}.c" # Check if files already exist if [ -f "$JCL_FILE" ]; then echo "Error: JCL file '$JCL_FILE' already exists" exit 1 fi if [ -f "$SRC_FILE" ]; then echo "Error: Source file '$SRC_FILE' already exists" exit 1 fi # Create JCL from template if [ ! -f "jcl/TEMPLATE.jcl" ]; then echo "Error: Template file 'jcl/TEMPLATE.jcl' not found" exit 1 fi echo "Creating new C project: $NAME" echo "" # Replace {NAME} placeholders in template sed "s/{NAME}/$NAME/g" jcl/TEMPLATE.jcl > "$JCL_FILE" echo "✓ Created JCL: $JCL_FILE" # Create empty C source file touch "$SRC_FILE" echo "✓ Created source: $SRC_FILE" echo "" echo "Project '$NAME' created successfully!" echo "Next steps:" echo " 1. Edit $SRC_FILE with your C code" echo " 2. Commit and push to trigger mainframe build"