|
|
@@ -70,8 +70,9 @@ dir_has_markers() {
|
|
|
grep -rqlE '@(host|group) ' "$1" 2>/dev/null
|
|
|
}
|
|
|
|
|
|
-# Detect the comment prefix from the first marker line in a file
|
|
|
-detect_comment_prefix() {
|
|
|
+# Detect the comment style from the first marker line in a file
|
|
|
+# Returns "block" for /* */ style, or the line-comment prefix (# // ; --)
|
|
|
+detect_comment_style() {
|
|
|
local src="$1"
|
|
|
local marker_line
|
|
|
marker_line=$(grep -m1 -E '@(host|group) ' "$src")
|
|
|
@@ -79,7 +80,12 @@ detect_comment_prefix() {
|
|
|
local prefix="${marker_line%%@*}"
|
|
|
# Trim trailing whitespace
|
|
|
prefix="${prefix%"${prefix##*[![:space:]]}"}"
|
|
|
- echo "$prefix"
|
|
|
+ # Check if it's a block comment opener
|
|
|
+ if [[ "$prefix" == "/*" ]]; then
|
|
|
+ echo "block"
|
|
|
+ else
|
|
|
+ echo "$prefix"
|
|
|
+ fi
|
|
|
}
|
|
|
|
|
|
# Process a file with @host/@group markers, outputting only matching sections
|
|
|
@@ -320,12 +326,16 @@ sub_sync(){
|
|
|
rm "$dest"
|
|
|
fi
|
|
|
|
|
|
- local comment_prefix
|
|
|
- comment_prefix=$(detect_comment_prefix "$src")
|
|
|
+ local comment_style
|
|
|
+ comment_style=$(detect_comment_style "$src")
|
|
|
|
|
|
{
|
|
|
- echo "$comment_prefix DO NOT EDIT - Generated by dotsync from:"
|
|
|
- echo "$comment_prefix $src"
|
|
|
+ if [[ "$comment_style" == "block" ]]; then
|
|
|
+ echo "/* DO NOT EDIT - Generated by dotsync from: $src */"
|
|
|
+ else
|
|
|
+ echo "$comment_style DO NOT EDIT - Generated by dotsync from:"
|
|
|
+ echo "$comment_style $src"
|
|
|
+ fi
|
|
|
echo ""
|
|
|
process_markers "$src"
|
|
|
} > "$dest.dotsync_tmp"
|