@@ -91,6 +91,8 @@ class OSFS(FS):
9191 create_mode (int): The permissions that will be used to create
9292 the directory if ``create`` is `True` and the path doesn't
9393 exist, defaults to ``0o777``.
94+ expand_vars(bool): If `True` (the default) environment variables of
95+ the form $name or ${name} will be expanded.
9496
9597 Raises:
9698 `fs.errors.CreateFailed`: If ``root_path`` does not
@@ -108,6 +110,7 @@ def __init__(
108110 root_path , # type: Text
109111 create = False , # type: bool
110112 create_mode = 0o777 , # type: SupportsInt
113+ expand_vars = True , # type: bool
111114 ):
112115 # type: (...) -> None
113116 """Create an OSFS instance.
@@ -118,7 +121,9 @@ def __init__(
118121 self .root_path = root_path
119122 _drive , _root_path = os .path .splitdrive (fsdecode (fspath (root_path )))
120123 _root_path = _drive + (_root_path or "/" ) if _drive else _root_path
121- _root_path = os .path .expanduser (os .path .expandvars (_root_path ))
124+ _root_path = os .path .expanduser (
125+ os .path .expandvars (_root_path ) if expand_vars else _root_path
126+ )
122127 _root_path = os .path .normpath (os .path .abspath (_root_path ))
123128 self ._root_path = _root_path
124129
0 commit comments