mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-27 11:21:32 +00:00
When expanding vars allow using $$ for literal $
This commit is contained in:
parent
5ff66f6bfa
commit
aafd8a8da4
1 changed files with 4 additions and 1 deletions
|
|
@ -34,6 +34,9 @@ else:
|
|||
|
||||
|
||||
def expandvars(val: str, env: Mapping[str, str] = {}, fallback_to_os_env: bool = True) -> str:
|
||||
'''
|
||||
Expand $VAR and ${VAR} Use $$ for a literal $
|
||||
'''
|
||||
|
||||
def sub(m: Match) -> str:
|
||||
key = m.group(1) or m.group(2)
|
||||
|
|
@ -47,7 +50,7 @@ def expandvars(val: str, env: Mapping[str, str] = {}, fallback_to_os_env: bool =
|
|||
if '$' not in val:
|
||||
return val
|
||||
|
||||
return re.sub(r'\$(?:(\w+)|\{([^}]+)\})', sub, val)
|
||||
return re.sub(r'\$(?:(\w+)|\{([^}]+)\})', sub, val.replace('$$', '\0')).replace('\0', '$')
|
||||
|
||||
|
||||
def platform_window_id(os_window_id: int) -> Optional[int]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue