Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
347 stars 231 forks source link

"setup()" should deal with "zsh" #1139

Closed DanGrayson closed 4 years ago

DanGrayson commented 4 years ago

"zsh" doesn't read ".profile", so "setup()" doesn't result in adding anything to the PATH if "zsh" is your shell.

That shell reads "$ZDOTDIR/.zprofile", but the manual page gives no hint about the value of "ZDOTDIR"

mahrud commented 4 years ago

This was already fixed, see #1061.

DanGrayson commented 4 years ago

I'm not convinced the fix will work: it should target .zprofile instead of. zshrc, and do it even if the file doesn't exist.

mahrud commented 4 years ago

480e0899a4f49f2fd2a0bdd4d57c4f353afe4d34 closes this, however, new issues arise:

By the way, this website has a good summary of what various shells do: https://kb.iu.edu/d/abdy

DanGrayson commented 4 years ago

Oops, on the third point there is another file in play, too: "After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable."

mahrud commented 4 years ago

Also, setup() seems to leave a few temp files around without cleaning them up.

mahrud commented 4 years ago

@DanGrayson while doing this, do you mind also making the following change?

--- a/M2/cmake/startup.cmake
+++ b/M2/cmake/startup.cmake
@@ -54,7 +54,7 @@ set(mandir    ${prefix}/${CMAKE_INSTALL_MANDIR})
 set(docdir     ${prefix}/${CMAKE_INSTALL_DOCDIR})
 # These locations are Macaulay2 conventions
 set(libm2dir   ${libdir}/Macaulay2)
-set(emacsdir   ${datarootdir}/emacs/site-lisp)
+set(emacsdir   ${datarootdir}/emacs/site-lisp/Macaulay2)
 set(GFTABLESDIR        ${datarootdir}/Macaulay2/Core/factory/)
 set(packagesdir        ${datarootdir}/Macaulay2)
 set(programsdir        ${libexecdir}/Macaulay2/bin)

I made this change in configure.ac but forgot to do it for cmake!

DanGrayson commented 4 years ago

Sure.

DanGrayson commented 4 years ago

About point 1, I think .zprofile is the correct file for the commands, as they need to be done only once, not upon every invocation of the shell.

mahrud commented 4 years ago

About point 1, I think .zprofile is the correct file for the commands, as they need to be done only once, not upon every invocation of the shell.

It's up to you, I'm just bringing up what the documentation says:

... '.zprofile' is similar to `.zlogin' ... . '.zlogin' is not the place for alias definitions, options, environment variable settings, etc.; as a general rule, it should not change the shell environment at all. Rather, it should be used to set the terminal type and run a series of external commands (fortune, msgs, etc).

DanGrayson commented 4 years ago

That advice you quote from the documentation makes no sense at all.

DanGrayson commented 4 years ago

There are lots of different shells out there, so for fear of not handling one of them that we don't know about, I think I'll not check the SHELL environment variable.

(Here's the list in ubuntu: /bin/sh, /bin/dash, /bin/bash, /bin/rbash, /usr/bin/screen, /usr/bin/tmux, /bin/csh.)

DanGrayson commented 4 years ago

Does anyone know how to prevent zsh from printing an entire row of spaces before each prompt? It makes it unusable inside emacs, where the carriage return characters don't return the carriage.

DanGrayson commented 4 years ago

resolved by 4a66fd902328c1642298254215014d82bcb49caf

mahrud commented 4 years ago

@DanGrayson while doing this, do you mind also making the following change?

--- a/M2/cmake/startup.cmake
+++ b/M2/cmake/startup.cmake
@@ -54,7 +54,7 @@ set(mandir    ${prefix}/${CMAKE_INSTALL_MANDIR})
 set(docdir     ${prefix}/${CMAKE_INSTALL_DOCDIR})
 # These locations are Macaulay2 conventions
 set(libm2dir   ${libdir}/Macaulay2)
-set(emacsdir   ${datarootdir}/emacs/site-lisp)
+set(emacsdir   ${datarootdir}/emacs/site-lisp/Macaulay2)
 set(GFTABLESDIR        ${datarootdir}/Macaulay2/Core/factory/)
 set(packagesdir        ${datarootdir}/Macaulay2)
 set(programsdir        ${libexecdir}/Macaulay2/bin)

I made this change in configure.ac but forgot to do it for cmake!

Can I push this directly to development?

DanGrayson commented 4 years ago

yes.

DanGrayson commented 4 years ago

Reopening, due to https://github.com/Macaulay2/M2/commit/4a66fd902328c1642298254215014d82bcb49caf#r40507676