Bug 167830 - Make sure that command line examples are shown correctly depending on OS
Summary: Make sure that command line examples are shown correctly depending on OS
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks: HelpGaps-NewFeatures Help-Changes-Features
  Show dependency treegraph
 
Reported: 2025-08-06 08:46 UTC by Mike Kaganski
Modified: 2025-10-24 14:23 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2025-08-06 08:46:24 UTC
Ref: https://ask.libreoffice.org/t/cant-start-libreoffice-with-socket-settings/125164/2
Ref: https://ask.libreoffice.org/t/passing-in-json-parameters-into-writer-for-the-convert-to-option/88142
and many more.

Some examples in help quote command line parameters. That is system-dependent; Linux command line may accept single-qouted parameters, while on Windows, cmd.exe doesn't.

Of course, it's also shell-dependent; e.g., the syntax differs between cmd.exe ad powershell (and even between different powershell versions, sigh).

We need to make system variants; and also always explicitly mention, which shell that is.
Comment 1 Olivier Hallot 2025-10-21 22:31:43 UTC
We can distinguish between WIN, UNIX and MAC operating systems in the help, but beyond that, the type of shell is not implemented as selector in the Help. 

Besides, the many possible shells can be hard to document all of them.

We expect that command line users are savvy in shell use.

Suggest WONTFIX.

Feel free to reopen if you disagree.
Comment 2 Mike Kaganski 2025-10-22 04:32:10 UTC
(In reply to Olivier Hallot from comment #1)

I disagree.
As I wrote:

> We need to make system variants; and also always explicitly mention, which
> shell that is.

And *that* is definitely doable. We must *make system variants* - for most common shell on the platform; and we must *mention* the shell used in the example.
Comment 3 fpy 2025-10-22 06:53:06 UTC
documenting shell (or any exec wrapper) specifics seems beyong LO scope.
(maybe extended examples on wiki)

but having a warning/disclaimer about quotes makes definitely sense.
  

In https://help.libreoffice.org/latest/en-US/text/shared/guide/start_parameters.html
existing "warnings" could be made less "generic"

- ... The use of command line parameters is only recommended for experienced users.
- For normal handling, the use of command line parameters is not necessary. A few of the parameters require a deeper knowledge of the technical background of LibreOffice software technology.


This one even is sounds superfluous

- Starting LibreOffice Software From the Command Line
    Open a shell under Linux, *BSD, or macOS platforms. // Search for Run in the Windows Start menu
    Type the following line of text, then press Return:

This one should be a warning  (linked to -env: ) :
- LibreOffice requires write access to its user profile directory.

etc etc
Comment 4 Mike Kaganski 2025-10-22 07:24:20 UTC
(In reply to fpy from comment #3)
> documenting shell (or any exec wrapper) specifics seems beyong LO scope.

1. As long as we provide a command line example, documenting the environment where the example works *definitely is* in the scope of the help.

2. As long as there is a reasonable way to provide a useful example for a given OS, as opposed to useless bash example for Windows users, it **definitely is** in the scope of the help to provide a useful example.
Comment 5 fpy 2025-10-22 10:32:18 UTC
(In reply to Mike Kaganski from comment #4)
> documenting

almost agree, 
for the record, I make a distinction between /mentionning/ and /documenting/.

Q: are the double quotes of this example mandatory ? (on all OSes). Or optional or replaced by single quotes ?

  ... pdf:draw_pdf_Export:{"PageRange":{"type":"string","value":"2-"}}
Comment 6 Mike Kaganski 2025-10-22 10:52:48 UTC
(In reply to fpy from comment #5)
> almost agree, 
> for the record, I make a distinction between /mentionning/ and /documenting/.

Which makes no sense at all. As usual, nonsensical "disagreement" dilutes the original idea, and prevents useful implementation.

The examples are there. They are provided after testing in *some* environment (or that must be so; if not, it's a problem of the one who created the example). This is the final fact; and here, *mentioning* which environment (here: shell flavor) this example works in, is exactly the same as *documenting* this environment.

The original comment 0 already used the wording "explicitly mention, which shell that is". There was no mention that we need to differentiate the shown example based on the shell that user uses (even though that is *possible* - in a *different* way, similar to how many API documentations provide a variety of examples, sometimes as "tabbed" box with tabs representing different programming languages; nothing prevents us from providing a similar thing, with tabs for bash/csh/..., and for cmd/powershell/...) - but THAT WAS NOT the topic here, and comment 1 somehow assumed what was not here. Only OS-based differentiation was proposed, with the obvious "use example with the default / most-used / reasonable shell for the OS, and mention that shell".

> Q: are the double quotes of this example mandatory ? (on all OSes). Or
> optional or replaced by single quotes ?
> 
>   ... pdf:draw_pdf_Export:{"PageRange":{"type":"string","value":"2-"}}

Which is another off-topic here. Please don't hijack this. If you have a question, ask on Ask LibreOffice.
Comment 7 fpy 2025-10-22 11:05:26 UTC
oops. forgot your narrow minded and insulting signature.
fair enough.
Comment 8 fpy 2025-10-22 11:06:48 UTC
(In reply to Mike Kaganski from comment #6)
> If you have a question, ask on Ask LibreOffice.

be sure I won't :(
Comment 9 Olivier Hallot 2025-10-23 10:46:20 UTC
Trying myself to document the command lines examples, I feel the pain on writing the right CLI on windows 11 PowerShell.

To convert an odt file to PDF page 2 to 5 I was able to use the command below under cmd.exe:
----------------8<----------------
C:\Users\olivi>"c:\Program Files\LibreOffice\program\soffice.com" --convert-to pdf:writer_pdf_Export:{\"PageRange\":{\"type\":\"string\",\"value\":\"2-5\"}} C:\Users\olivi\Downloads\WG2508-IntroStyles.odt
----------------8<----------------

However under powershell, that is another story. The best so far was using 
----------------8<----------------
start-process 'C:\Program Files\LibreOffice\program\soffice' -ArgumentList "--convert-to pdf:writer_pdf_Export:{`"PageRange`":{`"type`":`"string`",`"value`":`"2-5`"}}","C:\Users\olivi\Downloads\WG2508-IntroStyles.odt"
----------------8<----------------

but it does not work and it seems the argument list is not parsed correctly. The  console shows 

----------------8<----------------
Could not find platform independent libraries <prefix>
convert C:\Users\olivi\Downloads\WG2508-IntroStyles.odt as a Writer document -> C:\Users\olivi\WG2508-IntroStyles.pdf using filter : writer_pdf_Export:{PageRange:{type:string,value:2-5}}
Overwriting: C:\Users\olivi\WG2508-IntroStyles.pdf
----------------8<----------------

Looks like the double quotes are discarded in the argument list.

note: The backtick (`) for escaping double quotes is dangerous as it also work as continuation line...

Help welcome in clarifying this PowewrShell issue.
Comment 10 Mike Kaganski 2025-10-23 10:56:30 UTC
(In reply to Olivier Hallot from comment #9)
> Help welcome in clarifying this PowewrShell issue.

https://ask.libreoffice.org/t/cli-convert-custom-page-range-to-pdf/108475/2

I will try myself, a bit later.
Comment 11 Mike Kaganski 2025-10-23 11:17:31 UTC Comment hidden (obsolete)
Comment 12 Mike Kaganski 2025-10-23 11:34:47 UTC
Please ignore my comment #11 - I was not paying due attention to the exported result.

So, using PowerShell 5.1, the following command seems to work for me (note that the leading & is part of the command, allowing to use the syntax as is, without start-process):

> & 'C:\Program Files\LibreOffice\program\soffice.com' --convert-to 'pdf:writer_pdf_Export:{\"PageRange\":{\"type\":\"string\",\"value\":\"3-4\"}}' --outdir C:\Downloads\ C:\Downloads\file.odt

For PowerShell 7.5.4, this works:

> & 'C:\Program Files\LibreOffice\program\soffice.com' --convert-to 'pdf:writer_pdf_Export:{"PageRange":{"type":"string","value":"3-4"}}' --outdir C:\Downloads\ C:\Downloads\file.odt

i.e., the single quotes escape inner double quotes.
Comment 13 Commit Notification 2025-10-24 10:15:06 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/aac8d60b47589c8ba6d5eda78dc6d901c80eaa79

tdf#167830 CLI examples for several shells.