★ wanayoo — archive 1999 https://github.com/tmux-python/tmuxp/issues/543Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable is not being set when environment value contains "-th" #543

Open
thamaraiselvam opened this issue Jan 28, 2020 · 1 comment

Comments

@thamaraiselvam
Copy link

@thamaraiselvam thamaraiselvam commented Jan 28, 2020

Problem

Environment variable is not being set in a weird case

tmuxp details

  • Python 2.7.16
  • /Users/thamaraiselvam/Documents/repositories/github.com/tmuxp/.venv/bin:/Users/thamaraiselvam/.rvm/gems/ruby-2.6.3/bin:/Users/thamaraiselvam/.rvm/gems/ruby-2.6.3@global/bin:/Users/thamaraiselvam/.rvm/rubies/ruby-2.6.3/bin:/usr/local/opt/helm@2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/thamaraiselvam/.rvm/gems/ruby-2.6.3/bin:/Users/thamaraiselvam/.rvm/gems/ruby-2.6.3@global/bin:/Users/thamaraiselvam/.rvm/rubies/ruby-2.6.3/bin:/usr/local/opt/helm@2/bin:/Users/thamaraiselvam/.rvm/bin:/Users/thamaraiselvam/development/flutter/bin:/usr/local/Cellar/node/12.10.0/bin/:/Users/thamaraiselvam/go/bin:/usr/local/opt/go/libexec/binP:/usr/local/opt/fzf/bin:/Users/thamaraiselvam/.rvm/bin:/Users/thamaraiselvam/development/flutter/bin:/usr/local/bin:/usr/local/Cellar/node/12.10.0/bin/:/Users/thamaraiselvam/go/bin:/usr/local/opt/go/libexec/binP
  • tmux 3.0a
  • tmuxp 1.5.4
  • tmux path: /usr/local/bin/tmux
  • tmuxp path: /usr/local/bin/tmux

output of tmux show-options -g

@battery_bar "#[bg=none]#[fg=colour196]◼#[fg=colour202]◻#[fg=colour208]◻#[fg=colour214]◻#[fg=colour220]◻#[fg=colour226]◻#[fg=colour190]◻#[fg=colour154]◻#[fg=colour118]◻#[fg=colour82]◻#[fg=colour196]"
@battery_bar_length auto
@battery_bar_palette gradient
@battery_bar_symbol_empty ◻
@battery_bar_symbol_full ◼
@battery_hbar "#[fg=colour196]▏"
@battery_hbar_palette gradient
@battery_percentage 9%
@battery_status ↓
@battery_status_charging ↑
@battery_status_discharging ↓
@battery_vbar "#[fg=colour196]▁"
@battery_vbar_palette gradient
@root !
activity-action other
assume-paste-time 1
base-index 1
bell-action any
default-command 
default-shell /bin/zsh
default-size 80x24
destroy-unattached off
detach-on-destroy on
display-panes-active-colour #00afff
display-panes-colour #00afff
display-panes-time 800
display-time 1000
history-limit 5000
key-table root
lock-after-time 0
lock-command "lock -np"
message-command-style fg=#ffff00,bg=#000000,bright
message-style fg=#000000,bg=#ffff00,bright
mouse on
prefix C-a
prefix2 None
renumber-windows on
repeat-time 600
set-titles on
set-titles-string "#h ❐ #S ● #I #W"
silence-action other
status on
status-bg #080808
status-fg #8a8a8a
status-format[0] "#[align=left range=left #{status-left-style}]#{T;=/#{status-left-length}:status-left}#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#{T:window-status-format}#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{window-status-current-style},default},#{window-status-current-style},#{window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#{T:window-status-current-format}#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{status-right-style}]#{T;=/#{status-right-length}:status-right}#[norange default]"
status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }"
status-interval 10
status-justify left
status-keys emacs
status-left "#[fg=#000000,bg=#ffff00,bold] ❐ #S #[fg=#ffff00,bg=default,none] "
status-left-length 1000
status-left-style fg=#8a8a8a,bg=#080808
status-position bottom
status-right "#(cut -c3- ~/.tmux.conf | sh -s _battery)#[fg=#080808,bg=default,none]#[fg=#8a8a8a,bg=#080808,none]#[fg=#e4e4e4]#[bg=none]#[none]#{?session_many_attached,👓,}#[fg=#e4e4e4]#[bg=none]#[none]#{?client_prefix,⌨,} #{@battery_status} #{@battery_bar} #{@battery_percentage} #[fg=#8a8a8a,bg=#080808,none]| %R #[fg=#8a8a8a,bg=#080808,none]| %d %b #[fg=#d70000,bg=#080808,none]#[fg=#e4e4e4,bg=#d70000,none] #(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D) #[fg=#e4e4e4,bg=#d70000,none]#[fg=#000000,bg=#e4e4e4,bold] #(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D) "
status-right-length 1000
status-right-style fg=#8a8a8a,bg=#080808
status-style fg=#8a8a8a,bg=#080808
update-environment[0] DISPLAY
update-environment[1] KRB5CCNAME
update-environment[2] SSH_ASKPASS
update-environment[3] SSH_AUTH_SOCK
update-environment[4] SSH_AGENT_PID
update-environment[5] SSH_CONNECTION
update-environment[6] WINDOWID
update-environment[7] XAUTHORITY
visual-activity off
visual-bell off
visual-silence off
word-separators " "

Environment

Darwin 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

Step 4: Describe the problem:

tmuxp is not setting environment variable which starts with -th

Steps to reproduce:

  1. create a session yaml file as following
session_name: test
windows:
- window_name: default
  panes: []
environment:
  ONE: th
  TWO: -th
  THREE: -th-
  1. tmuxp load session.yaml
  2. check following environments
 echo $ONE
 echo $TWO
 echo $THREE

only ONE will be there

Observed Results:

  • No error or warning when run with --log_level

Expected Results:

  • Should have set environment called $TWO and $THREE
@thamaraiselvam thamaraiselvam changed the title Environment variable not set in specific case Environment variable is not being set when environment value starts with -th Jan 28, 2020
@thamaraiselvam thamaraiselvam changed the title Environment variable is not being set when environment value starts with -th Environment variable is not being set when environment value contains "-th" Jan 28, 2020
@dineshba
Copy link

@dineshba dineshba commented Jan 30, 2020

Myself and @jpninanjohn debugged this issue. Our finding:

  1. Problem is for any env having -t in key or value
  2. This bug is present in libtmux library itself.

We are calling self.session.set_environment(option, value) at here which should properly set the env for the session. This internally calls session.cmd which has this snippet.

def cmd(self, *args, **kwargs):
        # if -t is not set in any arg yet
        if not any('-t' in text_type(x) for x in args):
            # insert -t immediately after 1st arg, as per tmux format
            new_args = [args[0]]
            new_args += ['-t', self.id]
            new_args += args[1:]
            args = new_args
        return self.server.cmd(*args, **kwargs)

This adds a key and value as -t and session id if it does not find -t in given args. This does not do an exact match. It matches -t even if it is contained in middle of the word also in which case no target session is added. Hence the arguments are set for current session instead of new session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.