doc: advice on complex quoting use-cases (closes #1609)

This commit is contained in:
Dmitry Astapov 2021-07-18 11:40:39 +01:00 committed by Simon Michael
parent 8653510e3d
commit 50b915d12a
2 changed files with 20 additions and 0 deletions

View File

@ -35,6 +35,22 @@ https://github.com/simonmichael/hledger/blob/master/examples/roi-unrealised.ledg
- Cookbook -> [Return on Investment](return-on-investment.html) - Cookbook -> [Return on Investment](return-on-investment.html)
### Spaces and special characters in `--inv` and `--pnl`
Note that `--inv` and `--pnl`'s argument is a query, and queries could have several space-separated terms (see [QUERIES](https://hledger.org/hledger.html#queries)).
To indicate that all search terms form single command-line argument, you will need to put them in quotes (see [Special characters](https://hledger.org/hledger.html#special-characters)):
```shell
$ hledger roi --inv 'term1 term2 term3 ...'
```
If any query terms contain spaces themselves, you will need an extra level of nested quoting, eg:
```shell
$ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'"
```
### Semantics of `--inv` and `--pnl` ### Semantics of `--inv` and `--pnl`
Query supplied to `--inv` has to match all transactions that are Query supplied to `--inv` has to match all transactions that are

View File

@ -197,6 +197,10 @@ or:
$ hledger register credit\ card $ hledger register credit\ card
``` ```
Windows users should keep in mind that `cmd` treats single quote as a
regular character, so you should be using double quotes exclusively.
PowerShell treats both single and double quotes as quotes.
### Double escaping (regular expression metacharacters) ### Double escaping (regular expression metacharacters)
Characters significant in [regular expressions] Characters significant in [regular expressions]