@@ -993,6 +993,7 @@ def main(
993993 prog_name : t .Optional [str ] = None ,
994994 complete_var : t .Optional [str ] = None ,
995995 standalone_mode : bool = True ,
996+ windows_expand_args : bool = True ,
996997 ** extra : t .Any ,
997998 ) -> t .Any :
998999 """This is the way to invoke a script with all the bells and
@@ -1021,9 +1022,15 @@ def main(
10211022 propagated to the caller and the return
10221023 value of this function is the return value
10231024 of :meth:`invoke`.
1025+ :param windows_expand_args: Expand glob patterns, user dir, and
1026+ env vars in command line args on Windows.
10241027 :param extra: extra keyword arguments are forwarded to the context
10251028 constructor. See :class:`Context` for more information.
10261029
1030+ .. versionchanged:: 8.0.1
1031+ Added the ``windows_expand_args`` parameter to allow
1032+ disabling command line arg expansion on Windows.
1033+
10271034 .. versionchanged:: 8.0
10281035 When taking arguments from ``sys.argv`` on Windows, glob
10291036 patterns, user dir, and env vars are expanded.
@@ -1038,7 +1045,7 @@ def main(
10381045 if args is None :
10391046 args = sys .argv [1 :]
10401047
1041- if os .name == "nt" :
1048+ if os .name == "nt" and windows_expand_args :
10421049 args = _expand_args (args )
10431050 else :
10441051 args = list (args )
0 commit comments