jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1034543?usp=email )

Change subject: [doc] Add a hint how to use empty string arguments with 
PowerShell
......................................................................

[doc] Add a hint how to use empty string arguments with PowerShell

Bug: T364689
Change-Id: I1647f58ce09572322d9d836b79e509b9a5bd1167
---
M scripts/replace.py
1 file changed, 35 insertions(+), 15 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/replace.py b/scripts/replace.py
index e9f4db5..cb075d9 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -103,33 +103,51 @@

 -fullsummary      Use one large summary for all command line replacements.

-other:            First argument is the old text, second argument is the new
-                  text. If the -regex argument is given, the first argument
-                  will be regarded as a regular expression, and the second
-                  argument might contain expressions like \1 or \g<name>.
-                  It is possible to introduce more than one pair of old text
-                  and replacement.
+
+*Replacement parameters*
+    Replacement parameters are pairs of arguments given to the script.
+    The First argument is the old text to be replaced, the second
+    argument is the new text. If the ``-regex`` argument is given, the
+    first argument will be regarded as a regular expression, and the
+    second argument might contain expressions like ``\1`` or ``\g<name>``.
+    The second parameter can also be specified as empty string, usually
+    ``""``. It is possible to introduce more than one pair of
+    replacement parameters.
+
+.. admonition:: **Empty string arguments with PowerShell**
+   :class: attention
+
+   Using PowerShell as command shell removes empty strings during
+   PowerShell's command line parsing. To enable empty strings with
+   PowerShell you have either to escape quotation marks with gravis
+   symbols in front of them like ```"`"`` or to disable command line
+   parsing with ``--%`` symbol for all following command parts like
+   :samp:`python pwb replace --% -start:! foo ""` which disables parsing
+   for all replace options and arguments following this delimiter and
+   enables empty strings.

 Examples
 --------

-If you want to change templates from the old syntax, e.g. {{msg:Stub}}, to the
-new syntax, e.g. {{Stub}}, download an XML dump file (pages-articles) from
-https://dumps.wikimedia.org, then use this command:
+If you want to change templates from the old syntax, e.g.
+``{{msg:Stub}}``, to the new syntax, e.g. ``{{Stub}}``, download an XML
+dump file (pages-articles) from https://dumps.wikimedia.org, then use
+this command:

     python pwb.py replace -xml -regex "{{msg:(.*?)}}" "{{\1}}"

-If you have a dump called foobar.xml and want to fix typos in articles, e.g.
-Errror -> Error, use this:
+If you have a dump called ``foobar.xml`` and want to fix typos in
+articles, e.g. Errror -> Error, use this:

     python pwb.py replace -xml:foobar.xml "Errror" "Error" -namespace:0

 If you want to do more than one replacement at a time, use this:

     python pwb.py replace -xml:foobar.xml "Errror" "Error" "Faail" "Fail" \
--namespace:0
+    -namespace:0

-If you have a page called 'John Doe' and want to fix the format of ISBNs, use:
+If you have a page called 'John Doe' and want to fix the format of ISBNs,
+use:

     python pwb.py replace -page:John_Doe -fix:isbn

@@ -138,8 +156,10 @@

     python pwb.py replace referer referrer -file:typos.txt -excepttext:HTTP

-Please type "python pwb.py replace -help | more" if you can't read
-the top of the help.
+
+.. seealso:: :mod:`scripts.template` to modify or remove templates.
+.. Please type "python pwb.py replace -help | more" if you can't read
+   the top of the help.
 """
 #
 # (C) Pywikibot team, 2004-2024

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1034543?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1647f58ce09572322d9d836b79e509b9a5bd1167
Gerrit-Change-Number: 1034543
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to