All checks were successful
MVS Submit & Execute / upload-and-run (push) Successful in 6s
70 lines
1.7 KiB
Bash
Executable File
70 lines
1.7 KiB
Bash
Executable File
#!/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"
|
|
SRC_FILE="src/${NAME}.bas"
|
|
|
|
# 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 BAS 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 BASIC code"
|
|
echo " 2. Commit and push to trigger mainframe build"
|