tk5-basic-projects/newjob.sh

70 lines
1.7 KiB
Bash
Raw Normal View History

2026-02-17 21:32:14 +00:00
#!/bin/bash
# Script to create a new C project with JCL and source file
# Usage: ./newjob.sh <NAME>
# NAME must be 8 characters or less (MVS member name restriction)
set -e
if [ $# -ne 1 ]; then
echo "Usage: $0 <NAME>"
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"
2026-02-17 21:44:56 +00:00
SRC_FILE="src/${NAME}.bas"
2026-02-17 21:32:14 +00:00
# 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
2026-02-17 21:44:56 +00:00
echo "Creating new BAS project: $NAME"
2026-02-17 21:32:14 +00:00
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:"
2026-02-17 21:44:56 +00:00
echo " 1. Edit $SRC_FILE with your BASIC code"
2026-02-17 21:32:14 +00:00
echo " 2. Commit and push to trigger mainframe build"