Debian Codegraph @

docs/faqs.md

raw
1 # Frequently Asked Questions
2
3 ```{contents}
4 :depth: 2
5 :local: true
6 ```
7
8 ## General
9
10 ### Shell Variable Expansion On Windows
11
12 I have a simple Click app :
13
14 ```
15 import click
16
17 @click.command()
18 @click.argument('message')
19 def main(message: str):
20 click.echo(message)
21
22 if __name__ == '__main__':
23 main()
24
25 ```
26
27 When you pass an environment variable in the argument, it expands it:
28
29 ```{code-block} powershell
30 > Desktop python foo.py '$M0/.viola/2025-01-25-17-20-23-307878'
31 > M:/home/ramrachum/.viola/2025-01-25-17-20-23-307878
32 >
33 ```
34 Note that I used single quotes above, so my shell is not expanding the environment variable, Click does. How do I get Click to not expand it?
35
36 #### Answer
37
38 If you don't want Click to emulate (as best it can) unix expansion on Windows, pass windows_expand_args=False when calling the CLI.
39 Windows command line doesn't do any *, ~, or $ENV expansion. It also doesn't distinguish between double quotes and single quotes (where the later means "don't expand here"). Click emulates the expansion so that the app behaves similarly on both platforms, but doesn't receive information about what quotes were used.