I'm not sure if this is a bug or not.
Basically, if we use bash, then the subprocesses does not inherit the values of $LINES environment variable...
$ echo $LINES
100
$ bash -c 'echo $LINES'
$ bash -ic 'echo $LINES'
100
$
here, in the second invocation, $LINES environment variable is not inherited from the parent bash process.
However, in vim, $LINES are set globally -- if you execute the same commands in a :term inside vim,
the second line will also print out the number.
(note: I think https://stackoverflow.com/q/1780483/ says that these variables should be set "locally" only, but
it doesn't explain why.)
This is a problem because when I run :term in vim, then run ipython (now in vim/term os.environ["LINES"]
is a fixed value, while in xterm/bash it's not set), then run less from it, the LINES is fixed regardless of changes
to the environment variable. Unsetting LINES in ipython works as a workaround.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I think the code responsible for that is https://github.com/vim/vim/blob/67578e5bcf7404d40d42876b738b72e68add1a3e/src/os_unix.c#L4285
Maybe it's better to not set the environment variables instead, and let the subprocess e.g. bash detect it itself? Does it break anything?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I put a concrete use case which gets broken by vim's setting of environment variable.
This is a problem because when I run
:termin vim, then runipython(now in vim/termos.environ["LINES"]
is a fixed value, while in xterm/bash it's not set), then runlessfrom it, the LINES is fixed regardless of changes
to the environment variable. UnsettingLINESin ipython works as a workaround.
To clarify, I do this:
:term.ipython.ipython, run import sys.sys?. The less window is displayed correctly.vim.sys? again. The less window is garbled.—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Oh, I always thought it's the terminals responsibility to set the $LINES and $COLUMNS at least initially.
Now it may be fine for bash to automatically set the $LINES and $COLUMNS for the scripts it runs,
but keep in mind, you can also run the terminal like this :term script where no shell is involved and that called process
may still expect $LINES to be available (and not able to automatically determine $LINES) (e.g. running :term vim)
So I don't think removing LINES from the environment is a solution.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
but... if you run a script from bash the normal way, namely ./a.sh or bash a.sh then $LINES won't be set for the script anyway?
Unless you're running it like bash -i a.sh or source a.sh from bash, but then in that case the equivalent would be to do :term bash -i a.sh in vim.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
That comes back to what Gary said above. Several programs seem to require it, so it makes sense to export it.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I don't think this is a bug and therefore this is not going to change. let me close this therefore.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Closed #12160 as not planned.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()