Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Out of date environment variables value, after sourcing configuration file, when using the $name syntax #4629

@gpakosz

Description

@gpakosz

Issue description

Consider the following tmux.conf "base" configuration file:

var1=foo
source -qF '#{d:current_file}/optional.conf'
display "var1: $var1"
display "var2: $var2"

Then consider the optional optional.conf configuration file:

var1=bar
var2=fizz

When running tmux -vv -L test /tmp/tmux.conf, I get

tmp/tmux.conf:3: var1: foo
/tmp/tmux.conf:4: var2:

The manual says

Outside of quotes and inside double quotes, these replacements are performed:

  • Environment variables preceded by $ are replaced with their value from the global
    environment (see the GLOBAL AND SESSION ENVIRONMENT section).

Environment variables may be set by using the syntax ‘name=value’, for example ‘HOME=/home/user’.
Variables set during parsing are added to the global environment.

After tmux has launched, the global environment indeed contains the right values:

$ tmux showenv -g var1
var1=bar

$ tmux showenv -g var2
var2=fizz

Interestingly, when using the #{name} syntax, I get the desired behavior.

var1=foo
source -qF '#{d:current_file}/optional.conf'
display "var1: #{var1}"
display "var2: #{var2}"
$ tmux -L test /tmp/tmux.conf
/tmp/tmux.conf:3: var1: bar
/tmp/tmux.conf:4: var2: fizz

→ Is this something that should be fixed or documented?

Required information

  • tmux version (tmux -V): tmux 3.5a.
  • Platform (uname -sp): Darwin arm.
  • Terminal in use (xterm, rxvt, etc): Ghostty.
  • $TERM inside tmux (echo $TERM): tmux-256color.
  • $TERM outside tmux (echo $TERM): xterm-256color.
  • Logs from tmux (tmux kill-server; tmux -vv new).
    tmux-client-57016.log
    tmux-out-57018.log
    tmux-server-57018.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions