Skip to content

Instantly share code, notes, and snippets.

@Yousha
Created April 8, 2025 16:09
Show Gist options
  • Save Yousha/3bce677eed7c72d31302deb633253469 to your computer and use it in GitHub Desktop.
Save Yousha/3bce677eed7c72d31302deb633253469 to your computer and use it in GitHub Desktop.
Fixes makefile error: *** missing separator. Stop.
#!/bin/bash
# File to fix.
MAKEFILE="Makefile"
# Check if the Makefile exists.
if [[ ! -f "$MAKEFILE" ]]; then
echo "Error: $MAKEFILE not found in the current directory."
exit 1
fi
# Create a temporary file.
TEMP_FILE="Makefile.tmp"
# Process the Makefile, replacing space-indented lines with tabs.
awk '{
# Replace lines that start with spaces and a command-like structure
if ($0 ~ /^[[:space:]]+[^[:space:]]/)
sub(/^[[:space:]]+/, "\t");
print
}' "$MAKEFILE" > "$TEMP_FILE"
# Replace the original Makefile with the fixed one.
mv "$TEMP_FILE" "$MAKEFILE"
echo "Fixed $MAKEFILE: All lines with incorrect indentation have been replaced with tab-indented lines."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment