Skip to content

Commit 962d5e0

Browse files
committed
DOC: configuration: explain the rules regarding spaces in arguments
Spaces around commas or parenthesis in expressions are generally part of the value due to the long history of supporting unquoted arguments. But this tends to come as a surprise to new users and sometimes creates subtly invalid configurations. Let's add some text covering this. This can be backported to 2.4.
1 parent 12fcd65 commit 962d5e0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

doc/configuration.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,26 @@ double quotes inside (so that the double quotes are not stripped again):
852852
arg2 ___________/ /
853853
arg3 _______________/
854854

855+
But in this case it's important to note that delimiters embedded into the
856+
higher level string remain pure characters and are not delimiters anymore. It
857+
particularly means that spaces and tabs around commas are part of the string.
858+
The example below is wrong on multiple points:
859+
860+
http-request set-path '%[path, regsub("(foo|bar)", blah, g)]'
861+
------------ -------- --------------------------------------
862+
word1 word2 word3=%[path, regsub("(foo|bar)", blah, g)]
863+
|--------|---------||-----|--|
864+
converter=" regsub" _/ / / /
865+
arg1=(foo|bar) _/ / /
866+
arg2=" blah" ___________/ /
867+
arg3=" g" ______________/
868+
869+
The single fact of surrounding commas with spaces resulted in the spaces being
870+
part of the field itself, hence the converter " regsub" (starting with a
871+
space), which won't be found and will trigger an error, but more subtly, the
872+
replacement string " blah" will insert a space in the output. A good rule of
873+
thumb is to never insert unneeded spaces inside expressions.
874+
855875
When using regular expressions, it can happen that the dollar ('$') character
856876
appears in the expression or that a backslash ('\') is used in the replacement
857877
string. In this case these ones will also be processed inside the double quotes

0 commit comments

Comments
 (0)