Add --cmake option and .cmake file support to strip_c_comments_safe.sh

This commit is contained in:
copilot-swe-agent[bot] authored and GitHub committed 2026-07-14 09:42:46 +00:00
1 parent d3e9309e83
commit 24358e2588
1 file changed
+14
+14
View File
@@ -6,6 +6,7 @@ DRY_RUN=0
WITH_CPP=0
WITH_BASH=0
WITH_PYTHON=0
WITH_CMAKE=0
TARGET_DIR="."
usage() {
@@ -19,6 +20,7 @@ Optionen:
--cpp Zusätzlich auch C++-Dateien verarbeiten
--bash Zusätzlich auch Bash-Skripte (*.sh) verarbeiten
--python Zusätzlich auch Python-Skripte (*.py) verarbeiten
--cmake Zusätzlich auch CMake-Skripte (*.cmake) verarbeiten
-h, --help Hilfe anzeigen
Argumente:
@@ -31,6 +33,7 @@ Beispiele:
./strip_c_comments_safe.sh --cpp src
./strip_c_comments_safe.sh --bash scripts
./strip_c_comments_safe.sh --python tools
./strip_c_comments_safe.sh --cmake cmake
./strip_c_comments_safe.sh --cpp --backup-ext .orig ./project
EOF
}
@@ -61,6 +64,10 @@ while [[ $# -gt 0 ]]; do
WITH_PYTHON=1
shift
;;
--cmake)
WITH_CMAKE=1
shift
;;
-h|--help)
usage
exit 0
@@ -397,6 +404,9 @@ detect_mode() {
*.py)
echo "python"
;;
*.cmake)
echo "bash"
;;
*)
echo ""
;;
@@ -418,6 +428,10 @@ if [[ "$WITH_PYTHON" -eq 1 ]]; then
find_expr+=( -o -name "*.py" )
fi
if [[ "$WITH_CMAKE" -eq 1 ]]; then
find_expr+=( -o -name "*.cmake" )
fi
find "$TARGET_DIR" -type f \( "${find_expr[@]}" \) -print0 |
while IFS= read -r -d '' file; do
mode="$(detect_mode "$file")"