Core Library0.xAPI reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

function libtmux

_unescape_user_option_value

Decode a user-option value formatted by tmux args_escape (#{q/a:...}).

Source and package
Qualified name
libtmux.options._unescape_user_option_value
Module
libtmux.options
Package
libtmux
Source
src/libtmux/options.py
_unescape_user_option_value (raw: str) → str

Description

tmux formats string options in show-options through args_escape (arguments.c), which encodes tabs, newlines, backslashes, and control bytes with utf8_strvis even when no outer quotes are added. Passing unquoted a\nb to shlex.split would strip the backslash and return "anb".

In args_escape, $ is in dquoted, so any multi-character value containing $ sets VIS_DQ and emits 2k + 1 (odd) backslashes before $[A-Za-z_{]. tmux 3.4's server_client_print omits VIS_DQ and adds one more backslash there (2k + 2, nonzero even); dropping one backslash on an even run of length >= 2 before $[A-Za-z_{] decodes both losslessly.

Parameters

Examples

>>> _unescape_user_option_value("''")
''
>>> _unescape_user_option_value(r"a\nb")
'a\nb'
>>> _unescape_user_option_value('"both\\"and\'"')
'both"and\''
>>> _unescape_user_option_value(r'"\$HOME"')
'$HOME'
>>> _unescape_user_option_value(r'"\\$HOME"')
'$HOME'
>>> _unescape_user_option_value(r'"\\\$HOME"')
'\\$HOME'
>>> _unescape_user_option_value(r'"\\\\$HOME"')
'\\$HOME'

Recorded calls

source calls
No call edges in the Python model.

The Python reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls libtmux.options._unescape_user_option_value.

Esc
Search in

Type to search.

Reference previewOpen reference