Я использую следующую команду для извлечения описаний из патчей:
sed '
s/Title: \(.*\)/### \1 ###\n\n**File:** FILE_NAME_HERE/
/^diff\|^---/ {
q
}
' "$patch" | egrep -v '^(diff|---)'
Как мне избавиться от части egrep -v '^(diff|---)'
и использовать только sed? Я пытался сделать это:
/^diff\|^---/ {
d # <-- This is what I added
q
}
Но как только эта "d" достигнута, "q" пропускается, а остальные строки в теле патча печатаются. Вот пример патча:
Title: Font Array Support
Modifies st to support user-defined fallback fonts specified in an array
defined as `static const char *fonts[]`. This change also resolves an issue
where fallback fonts were used in place of default fonts in an inconsistent
manner which caused identical sets of text to sometimes use different fonts. In
the following example, DejaVu Sans Mono is the primary font with two others
specified as fallbacks:
static const char *fonts[] = {
"DejaVu Sans Mono",
"VL Gothic",
"WenQuanYi Micro Hei",
};
diff --git a/st.c b/st.c
index 2594c65..f7973bd 100644
--- a/st.c
+++ b/st.c
@@ -353,10 +353,17 @@ typedef struct {
FcPattern *pattern;
} Font;
Сценарий sed должен возвращать все, что находится выше строки, начинающейся с «diff;» вот что должно быть на выходе:
Title: Font Array Support
Modifies st to support user-defined fallback fonts specified in an array
defined as `static const char *fonts[]`. This change also resolves an issue
where fallback fonts were used in place of default fonts in an inconsistent
manner which caused identical sets of text to sometimes use different fonts. In
the following example, DejaVu Sans Mono is the primary font with two others
specified as fallbacks:
static const char *fonts[] = {
"DejaVu Sans Mono",
"VL Gothic",
"WenQuanYi Micro Hei",
};