Skip to contentSkip to conversation

build: add missing backslash to build_man.sh

PATCH In review Duncan Roe 2 participants 7 messages Oct 4, 2024 – Oct 12, 2024 netfilter

lore
Share & tools
lore

Duncan Roe

author
#0 lore raw

PATCH 1/1 build: add missing backslash to build_man.sh

Search for exact match of ".RI" had a '\' to escape '.' from the regexp parser but was missing another '\' to escape the 1st '\' from shell. Had not yet caused a problem but might as well do things correctly.

Fixes 6d17e6daa175
---
 doxygen/build_man.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doxygen/build_man.sh +1 -1
index c0124e2..8f1852a 100755
@@ -43,7 +43,7 @@ rename_real_pages(){
   do
     j=$(ed -s $i <<////
 /Functions/+1;.#
-/^\.RI/;.#
+/^\\.RI/;.#
 .,.s/^.*\\\\fB//
 .,.s/\\\\.*//
 .,.w /dev/stdout
Signature · 1 line
2.39.4
reviewer
#1 lore raw

Hi Duncan,

Quoted 3 lines · Duncan Roe

Search for exact match of ".RI" had a '\' to escape '.' from the regexp parser but was missing another '\' to escape the 1st '\' from shell. Had not yet caused a problem but might as well do things correctly.

Your patch looks correct and bash(1) confirms the need for escaping:

"If any part of word is quoted, the delimiter is the result of quote removal on word, and the lines in the here-document are not expanded. If word is unquoted, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion, the character sequence \<newline> is ignored, and \ must be used to quote the characters \, $, and `."

This holds another interesting detail, though: By quoting your delimiter, you may disable expansion entirely which might improve readability in those ed commands?

Cheers, Phil

author
#2 lore raw

Hi Phil,

Quoted 3 lines · Phil Sutter

This holds another interesting detail, though: By quoting your delimiter, you may disable expansion entirely which might improve readability in those ed commands?

I did try quoting the delimiter when I was working on speeding up build_man.sh. Rather to my surprise, the used CPU went up albeit by a tiny amount. I was absolutely focussed on speed so left the delimiter unquoted.

The CPU increase was so small that you might consider the improvement in readability to be worth it.

But there is another possible downside to quoting the delimiter. Some of the here documents in build_man contain actual parameter substitution so would have to be left as_is, leading to inconsistent appearance of here documents.

I'm happy to do it either way, LMK your preference.

Cheers ... Duncan.

reviewer
#3 lore raw

Hi Duncan,

Quoted 8 lines · Duncan Roe
Quoted 3 lines · Phil Sutter

This holds another interesting detail, though: By quoting your delimiter, you may disable expansion entirely which might improve readability in those ed commands?

I did try quoting the delimiter when I was working on speeding up build_man.sh. Rather to my surprise, the used CPU went up albeit by a tiny amount. I was absolutely focussed on speed so left the delimiter unquoted.

That's odd - while the shell will have to unquote the delimiter, it should have less work with the content. Are you sure this is not just noise you were measuring?

Quoted 6 lines

The CPU increase was so small that you might consider the improvement in readability to be worth it.

But there is another possible downside to quoting the delimiter. Some of the here documents in build_man contain actual parameter substitution so would have to be left as_is, leading to inconsistent appearance of here documents.

Sure!

Quoted 1 line

I'm happy to do it either way, LMK your preference.

I don't have any, just stumbled upon this feature when checking for when/why unescaped backslashes are interpreted or not.

Cheers, Phil

author
#4 lore raw
Quoted 4 lines · Phil Sutter

That's odd - while the shell will have to unquote the delimiter, it should have less work with the content. Are you sure this is not just noise you were measuring?

It sure surprised the hell out of me. I do know a bit about eperimental technique having studied honours physics, so I reversed the test a few times. The unquoted delimiter was always faster. The difference was very small but statistically significant.

Cheers ... Duncan.

author
#5 lore raw
In reply to Phil Sutter

Hi Phil,

Quoted 6 lines · Phil Sutter
Quoted 1 line · Duncan Roe

I'm happy to do it either way, LMK your preference.

I don't have any, just stumbled upon this feature when checking for when/why unescaped backslashes are interpreted or not.

I'll leave it as_is then.

Can somebody please apply this patch?

Cheers ... Duncan.

reviewer
#6 lore raw
In reply to Duncan Roe
Quoted 6 lines · Duncan Roe

Search for exact match of ".RI" had a '\' to escape '.' from the regexp parser but was missing another '\' to escape the 1st '\' from shell. Had not yet caused a problem but might as well do things correctly.

Fixes 6d17e6daa175

Patch applied, thanks!