You are not logged in.

#1 2023-07-09 05:48:22

dtjohnst
Member
Registered: 2007-03-01
Posts: 85

$EDITOR and $VISUAL ignored by git and sudoedit [SOLVED]

I'm not quite sure what I've done wrong here, but the EDITOR and VISUAL environment variables are being ignored and I have no idea why. I feel like this was working fine, but as far as I'm aware I haven't changed anything.

% printf 'EDITOR: %s\nVISUAL: %s\nSUDO: %s\nGIT: %s\n' $EDITOR $VISUAL $SUDO_EDITOR $GIT_EDITOR
EDITOR: /usr/bin/nvim
VISUAL: /usr/bin/nvim
SUDO:
GIT:
% sudoedit /etc/pacman.conf
sudoedit: /usr/bin/vi: command not found
% git --git-dir="$HOME/.config/dotfiles" --work-tree="$HOME" commit
hint: Waiting for your editor to close the file... error: cannot run vi: No such file or directory
error: unable to start editor 'vi'
Please supply the message using either -m or -F option

As far as I can tell, both git and sudoedit should be using the VISUAL or EDITOR environment variable if they are set and SUDO_EDITOR or GIT_EDITOR are not.

Last edited by dtjohnst (2023-07-09 21:28:09)

Offline

#2 2023-07-09 06:49:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,129

Re: $EDITOR and $VISUAL ignored by git and sudoedit [SOLVED]

printenv | grep vi

Offline

#3 2023-07-09 07:09:26

dtjohnst
Member
Registered: 2007-03-01
Posts: 85

Re: $EDITOR and $VISUAL ignored by git and sudoedit [SOLVED]

Nothing returned.

Edit: That doesn't seem right though, does it? Shouldn't both EDITOR and VISUAL be returned as 'vi' is in 'nvim'?

Last edited by dtjohnst (2023-07-09 07:15:58)

Offline

#4 2023-07-09 09:17:51

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,129

Re: $EDITOR and $VISUAL ignored by git and sudoedit [SOLVED]

Yup.
The variables are either not exported or something™ clears the environment on any execv…

export EDITOR=foo
export foo=bar
printenv | grep foo
export EDITOR=nvim
export VISUAL=nvim
printenv | grep nvim
sudoedit /etc/pacman.conf

Offline

#5 2023-07-09 21:27:56

dtjohnst
Member
Registered: 2007-03-01
Posts: 85

Re: $EDITOR and $VISUAL ignored by git and sudoedit [SOLVED]

I'm not quite sure why, but it seems set -a wasn't quite working right. My understanding is that it should enable all defined variables to be exported. For example:

% SOMEVAR="hi"
% printenv SOMEVAR
% set -a
% SOMEVAR="hi"
% printenv SOMEVAR
hi

This works as I expected. But my .zshenv file was as follows:

% cat .zshenv
set -a

LS_COLORS='no=00:rs=0:fi=00:di=01;<cut for space>:';
ZLSCOLORS="${LS_COLORS}"
DIFFPROG="/usr/bin/nvim -d"
EDITOR="/usr/bin/nvim"
LESS=eFRX
LESSHISTFILE=-
PAGER="/usr/bin/less"
VISUAL="/usr/bin/nvim"

set +a

And that didn't work. Removing the set commands and prefixing all the variables with export works correctly though. I'm not quite sure why set wasn't working and would appreciate some enlightenment if anyone knows, but at least things are working now.

Offline

#6 2023-07-10 06:57:37

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,129

Re: $EDITOR and $VISUAL ignored by git and sudoedit [SOLVED]

Does "un/setopt allexport" (still) work?

Offline

Board footer

Powered by FluxBB