diff --git a/make_openapi_client.sh b/make_openapi_client.sh index 6c0cda2..9c2fd4f 100755 --- a/make_openapi_client.sh +++ b/make_openapi_client.sh @@ -3,15 +3,16 @@ # Extract values from pyproject.toml PYPROJECT_FILE="$(dirname "$0")/pyproject.toml" -VERSION=$(grep -Po '(?<=version = ")[^"]*' "$PYPROJECT_FILE") -NAME=$(grep -Po '(?<=name = ")[^\"]*' "$PYPROJECT_FILE" | sed 's/[^a-zA-Z0-9_-]//g') # Extract name and sanitize it +# Extract name directly and ignore newlines +NAME=$(awk -F'=' '/^name/ { gsub(/"/, "", $2); print $2 }' "$PYPROJECT_FILE" | xargs) +VERSION=$(awk -F'=' '/^version/ { gsub(/"/, "", $2); print $2 }' "$PYPROJECT_FILE" | xargs) if [[ -z "$VERSION" || -z "$NAME" ]]; then echo "Error: Could not determine version or name from pyproject.toml" exit 1 fi -# Ensure NAME is valid (no special characters or newlines) +# Ensure the extracted name is valid (No spaces or unexpected characters) if ! [[ "$NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "Error: Invalid project name detected: '$NAME'" exit 1