_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
-
Description
tmux formats string options in
show-optionsthroughargs_escape(arguments.c), which encodes tabs, newlines, backslashes, and control bytes withutf8_strviseven when no outer quotes are added. Passing unquoteda\nbtoshlex.splitwould strip the backslash and return"anb".In
args_escape,$is indquoted, so any multi-character value containing$setsVIS_DQand emits2k + 1(odd) backslashes before$[A-Za-z_{]. tmux 3.4'sserver_client_printomitsVIS_DQand adds one more backslash there (2k + 2, nonzero even); dropping one backslash on an even run of length>= 2before$[A-Za-z_{]decodes both losslessly.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 callsThe 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.