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

Only restores TERM when it's changed. #36

Merged
merged 1 commit into from
Feb 2, 2018
Merged

Only restores TERM when it's changed. #36

merged 1 commit into from
Feb 2, 2018

Conversation

livibetter
Copy link
Contributor

I'd like to switch to setenv, but I think that requires @abishekvashok's approval, I'd add another commit, if it's okay to switch.

I think the following comment might be outdated (no idea when it was commented):

cmatrix/cmatrix.c

Lines 387 to 391 in 5cfe816

if (force && strcmp("linux", getenv("TERM"))) {
/* Portability wins out here, apparently putenv is much more
common on non-Linux than setenv */
putenv("TERM=linux");
}

From manpage of setenv(3), it conforms to POSIX.1-2001, POSIX.1-2008, 4.3BSD, they were long ago, not sure if that statement in the comment still stands in the current status.

There are a few pages about putenv and setenv: 1, 2, 3.

Only when `-f` force `TERM=linux` is used and there was a change of
`$TERM`.

Since, the forcing the TERM uses `putenv(3)`, replaced `system(3)` call
to be consistent and to get rid of compilation warning of ignoring the
return value.

Note: using `setenv(3)` is cleaner, as we only needs to keep preserved
TERM value, no need to format a `"TERM=foobar"` string.  However, as the
comment L388 stated that `putenv` is more common on non-Linux, so
keeping this way.
@livibetter
Copy link
Contributor Author

livibetter commented Jan 31, 2018

I realized checking force is unnecessary, but I began to ponder of the usefulness of -f option, because:

TERM=linux cmatrix

Should do nearly the same, if we run in shell or the launcher supports environment variable settings, even the latter does not, a simple wrapping sh -c '...' would do.

Does anyone actually use the option? Do we really need it?


2018-01-31T05:12:45Z: env is more suitable to run with different environment.

@abishekvashok abishekvashok merged commit 93fd357 into abishekvashok:master Feb 2, 2018
@abishekvashok
Copy link
Owner

Thanks flr that. We can update to setenv() but that's not a priority. I've opened an issue #

@livibetter livibetter deleted the system-putenv branch February 4, 2018 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants