unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* move "source /etc/profile" from .zlogin to .zprofile
@ 2018-10-13 15:44 Meiyo Peng
  2018-10-14  1:33 ` Chris Marusich
  0 siblings, 1 reply; 10+ messages in thread
From: Meiyo Peng @ 2018-10-13 15:44 UTC (permalink / raw)
  To: guix-devel

Hello,

Guix's default skeletons put "source /etc/profile" into ~/.zlogin. But
/etc/profile resets the PATH environment variable, exports many other
environment variables, and source /etc/bashrc. According to
http://zsh.sourceforge.net/Intro/intro_3.html .zlogin is sourced after
.zshrc and should not be used for alias definitions, options,
environment variable settings, etc. Especially "as a general rule, it
should not change the shell environment at all". I think it's better to
source /etc/profile from ~/.zprofile.

Meiyo Peng

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-13 15:44 move "source /etc/profile" from .zlogin to .zprofile Meiyo Peng
@ 2018-10-14  1:33 ` Chris Marusich
  2018-10-14  1:56   ` Leo Famulari
  2018-10-14  3:14   ` Meiyo Peng
  0 siblings, 2 replies; 10+ messages in thread
From: Chris Marusich @ 2018-10-14  1:33 UTC (permalink / raw)
  To: Meiyo Peng; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

Hi Meiyo,

Meiyo Peng <meiyo.peng@gmail.com> writes:

> Guix's default skeletons put "source /etc/profile" into ~/.zlogin. But
> /etc/profile resets the PATH environment variable, exports many other
> environment variables, and source /etc/bashrc. According to
> http://zsh.sourceforge.net/Intro/intro_3.html .zlogin is sourced after
> .zshrc and should not be used for alias definitions, options,
> environment variable settings, etc. Especially "as a general rule, it
> should not change the shell environment at all". I think it's better to
> source /etc/profile from ~/.zprofile.

The same documentation you linked says:

    `.zprofile' is meant as an alternative to `.zlogin' for ksh fans;
    the two are not intended to be used together, although this could
    certainly be done if desired.

Is the intended use of .zprofile any different from the intended use of
.zlogin?  If .zprofile and .zlogin are both meant to serve the same
purpose, then I'm not sure why one would be preferable over the other.

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-14  1:33 ` Chris Marusich
@ 2018-10-14  1:56   ` Leo Famulari
  2018-10-14  6:30     ` Chris Marusich
  2018-10-14  3:14   ` Meiyo Peng
  1 sibling, 1 reply; 10+ messages in thread
From: Leo Famulari @ 2018-10-14  1:56 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

On Sat, Oct 13, 2018 at 06:33:59PM -0700, Chris Marusich wrote:
> The same documentation you linked says:
> 
>     `.zprofile' is meant as an alternative to `.zlogin' for ksh fans;
>     the two are not intended to be used together, although this could
>     certainly be done if desired.
> 
> Is the intended use of .zprofile any different from the intended use of
> .zlogin?  If .zprofile and .zlogin are both meant to serve the same
> purpose, then I'm not sure why one would be preferable over the other.

The difference is that they are used at different times — zprofile is
used before zshrc, whereas zlogin is used after zshrc.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-14  1:33 ` Chris Marusich
  2018-10-14  1:56   ` Leo Famulari
@ 2018-10-14  3:14   ` Meiyo Peng
  1 sibling, 0 replies; 10+ messages in thread
From: Meiyo Peng @ 2018-10-14  3:14 UTC (permalink / raw)
  To: cmmarusich; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

Hi Chris,

/etc/profile should do the preparation work for users settings in .zshrc.
But
since .zlogin is sourced after .zshrc, it will override users settings in
.zshrc. It resets $PATH and many other environment variables. This is
counterintuitive.

You can find what archlinux did here:
https://wiki.archlinux.org/index.php/Zsh

   - /etc/zsh/zprofile Used for executing commands at start, will be
   sourced when starting as a *login shell*. Please note that on Arch
   Linux, by default it contains one line
   <https://projects.archlinux.org/svntogit/packages.git/tree/trunk/zprofile?h=packages/zsh>
   which source the /etc/profile.
      - /etc/profile This file should be sourced by all Bourne-compatible
      shells upon login: it sets up $PATH and other environment variables
      and application-specific (/etc/profile.d/*.sh) settings upon login.
   - $ZDOTDIR/.zprofile Used for executing user's commands at start, will
   be sourced when starting as a *login shell*.
   - ...
   - $ZDOTDIR/.zshrc Used for setting user's interactive shell
   configuration and executing commands, will be sourced when starting
as an *interactive
   shell*.
   - ...
   - $ZDOTDIR/.zlogin Used for executing user's commands at ending of
   initial progress, will be sourced when starting as a *login shell*.


On Sun, Oct 14, 2018, 09:34 Chris Marusich <cmmarusich@gmail.com> wrote:

>
> Is the intended use of .zprofile any different from the intended use of
> .zlogin?  If .zprofile and .zlogin are both meant to serve the same
> purpose, then I'm not sure why one would be preferable over the other.
>
>

[-- Attachment #2: Type: text/html, Size: 2331 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-14  1:56   ` Leo Famulari
@ 2018-10-14  6:30     ` Chris Marusich
  2018-10-14  7:58       ` Meiyo Peng
  2018-10-15  9:48       ` Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Chris Marusich @ 2018-10-14  6:30 UTC (permalink / raw)
  To: Leo Famulari, Meiyo Peng; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 1414 bytes --]

Hi Leo and Meiyo,

Leo Famulari <leo@famulari.name> writes:

> On Sat, Oct 13, 2018 at 06:33:59PM -0700, Chris Marusich wrote:
>> [...]  If .zprofile and .zlogin are both meant to serve the same
>> purpose, then I'm not sure why one would be preferable over the
>> other.
>
> The difference is that they are used at different times — zprofile is
> used before zshrc, whereas zlogin is used after zshrc.

Meiyo Peng <meiyo.peng@gmail.com> writes:

> [...] [S]ince .zlogin is sourced after .zshrc, it will override users
> settings in .zshrc. It resets $PATH and many other environment
> variables. This is counterintuitive.

I see.  I'm not a zsh user, but I agree it would make sense to rename
.zlogin to .zprofile.  I've attached a patch that does this in our
/etc/skel.  I haven't tested it, though.  Would you like to test it and
let me know if it works for you?

I see that zsh also sources files like /etc/zprofile when they exist.  I
don't have a strong preference for putting this into /etc/zprofile
vs. putting it into ~/.zprofile (via /etc/skel).  What do you think
about that?

Can anybody think of anything bad that might happen if we apply the
attached patch?  It seems reasonable and safe to me, but you never know!
I've always found the relationship between shell start-up scripts to be
confusing; everyone seems to want to configure them differently.

-- 
Chris

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-system-Rename-.zlogin-to-.zprofile.patch --]
[-- Type: text/x-patch, Size: 1526 bytes --]

From a80c1f231f0c94a2b2c3780039b3f6fc2957c2be Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Sat, 13 Oct 2018 22:50:36 -0700
Subject: [PATCH] system: Rename .zlogin to .zprofile.

* gnu/system/shadow.scm (default-skeletons): Rename zlogin to zprofile.
---
 gnu/system/shadow.scm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index f800c3b54..63f544cec 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -181,7 +181,7 @@ fi
 alias ls='ls -p --color=auto'
 alias ll='ls -l'
 alias grep='grep --color=auto'\n"))
-        (zlogin    (plain-file "zlogin" "\
+        (zprofile    (plain-file "zprofile" "\
 # Honor system-wide environment variables
 source /etc/profile\n"))
         (guile-wm  (computed-file "guile-wm" copy-guile-wm))
@@ -197,7 +197,10 @@ set debug-file-directory ~/.guix-profile/lib/debug
 set auto-load safe-path /gnu/store/*/lib\n")))
     `((".bash_profile" ,profile)
       (".bashrc" ,bashrc)
-      (".zlogin" ,zlogin)
+      ;; Zsh sources ~/.zprofile before ~/.zshrc, and it sources ~/.zlogin
+      ;; after ~/.zshrc.  To avoid interfering with any customizations a user
+      ;; may have made in their ~/.zshrc, put this in .zprofile, not .zlogin.
+      (".zprofile" ,zprofile)
       (".nanorc" ,(plain-file "nanorc" "\
 # Include all the syntax highlighting modules.
 include /run/current-system/profile/share/nano/*.nanorc\n"))
-- 
2.18.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-14  6:30     ` Chris Marusich
@ 2018-10-14  7:58       ` Meiyo Peng
  2018-10-15  9:48       ` Ludovic Courtès
  1 sibling, 0 replies; 10+ messages in thread
From: Meiyo Peng @ 2018-10-14  7:58 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

Hi Chris,

On Sun, Oct 14, 2018 at 6:30 AM Chris Marusich wrote:

> I haven't tested it, though.  Would you like to test it and
> let me know if it works for you?

Guix is still new to me, and I don't know how to apply the patch and
build guix. But I moved "source /etc/profile" from my .zlogin to
.zprofile and I have no problem.

> I see that zsh also sources files like /etc/zprofile when they exist.  I
> don't have a strong preference for putting this into /etc/zprofile
> vs. putting it into ~/.zprofile (via /etc/skel).  What do you think
> about that?

Usually I prefer to put less dot files in my $HOME directory. But I'm OK
with guix's solution.

> I've always found the relationship between shell start-up scripts to be
> confusing; everyone seems to want to configure them differently.

I agree. So I prefer to use fish shell, which is simpler. But I have to
temporarily switch to zsh until this bug is fixed:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30265

[-- Attachment #2: Type: text/html, Size: 1203 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-14  6:30     ` Chris Marusich
  2018-10-14  7:58       ` Meiyo Peng
@ 2018-10-15  9:48       ` Ludovic Courtès
  2018-10-16  4:59         ` Leo Famulari
  1 sibling, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2018-10-15  9:48 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

Hello,

Chris Marusich <cmmarusich@gmail.com> skribis:

> I see.  I'm not a zsh user, but I agree it would make sense to rename
> .zlogin to .zprofile.  I've attached a patch that does this in our
> /etc/skel.  I haven't tested it, though.  Would you like to test it and
> let me know if it works for you?

I don’t use Zsh either; IMO, if Meiyo and other Zsh users think it’s the
right thing, go for it!

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-15  9:48       ` Ludovic Courtès
@ 2018-10-16  4:59         ` Leo Famulari
  2018-10-16 11:55           ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Famulari @ 2018-10-16  4:59 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

On Mon, Oct 15, 2018 at 11:48:01AM +0200, Ludovic Courtès wrote:
> Hello,
> 
> Chris Marusich <cmmarusich@gmail.com> skribis:
> 
> > I see.  I'm not a zsh user, but I agree it would make sense to rename
> > .zlogin to .zprofile.  I've attached a patch that does this in our
> > /etc/skel.  I haven't tested it, though.  Would you like to test it and
> > let me know if it works for you?
> 
> I don’t use Zsh either; IMO, if Meiyo and other Zsh users think it’s the
> right thing, go for it!

I use Zsh as my interactive shell and I use zprofile for everything,
either in /etc or my home directory. I don't even have a zlogin file.
So, I think it will work :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-16  4:59         ` Leo Famulari
@ 2018-10-16 11:55           ` Ludovic Courtès
  2018-10-19  7:47             ` Chris Marusich
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2018-10-16 11:55 UTC (permalink / raw)
  To: Leo Famulari; +Cc: guix-devel

Leo Famulari <leo@famulari.name> skribis:

> On Mon, Oct 15, 2018 at 11:48:01AM +0200, Ludovic Courtès wrote:
>> Hello,
>> 
>> Chris Marusich <cmmarusich@gmail.com> skribis:
>> 
>> > I see.  I'm not a zsh user, but I agree it would make sense to rename
>> > .zlogin to .zprofile.  I've attached a patch that does this in our
>> > /etc/skel.  I haven't tested it, though.  Would you like to test it and
>> > let me know if it works for you?
>> 
>> I don’t use Zsh either; IMO, if Meiyo and other Zsh users think it’s the
>> right thing, go for it!
>
> I use Zsh as my interactive shell and I use zprofile for everything,
> either in /etc or my home directory. I don't even have a zlogin file.
> So, I think it will work :)

Alright, so Chris you can probably go ahead and push the patch!

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: move "source /etc/profile" from .zlogin to .zprofile
  2018-10-16 11:55           ` Ludovic Courtès
@ 2018-10-19  7:47             ` Chris Marusich
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Marusich @ 2018-10-19  7:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

ludo@gnu.org (Ludovic Courtès) writes:

> Alright, so Chris you can probably go ahead and push the patch!

Sounds good!  I've committed this to master as
2f4d43584cb26315c028dfbd2197da0d175933a2.

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-10-19  7:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-13 15:44 move "source /etc/profile" from .zlogin to .zprofile Meiyo Peng
2018-10-14  1:33 ` Chris Marusich
2018-10-14  1:56   ` Leo Famulari
2018-10-14  6:30     ` Chris Marusich
2018-10-14  7:58       ` Meiyo Peng
2018-10-15  9:48       ` Ludovic Courtès
2018-10-16  4:59         ` Leo Famulari
2018-10-16 11:55           ` Ludovic Courtès
2018-10-19  7:47             ` Chris Marusich
2018-10-14  3:14   ` Meiyo Peng

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).