zsh-users
 help / color / mirror / Atom feed
* Fwd: sshfs crash with zsh
       [not found] <CAAg1DCMTC7tk-uTN0Twvj3pGeJRz_-3mpL6m-YrO-5cMXjsbow@mail.gmail.com>
@ 2020-08-12 10:13 ` Peter Stephenson
  2020-08-12 15:55   ` Phil Pennock
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2020-08-12 10:13 UTC (permalink / raw)
  To: zsh-user

From: Rui Dong <rdong1989@gmail.com>
To: coordinator@zsh.org
Date: 12 August 2020 at 01:25
Subject: sshfs crash with zsh

Hi Peter,

I am a fan of zsh, and used it for many years. Recently I found when I
configure the server with zsh, I could not mount the disk with sshfs. If I
comment the "exec /bin/zsh --login" out, sshfs works again. Could you
please help with this?
Thanks for your help.

Best,
Rui

-- 
Rui Dong
Postdoctoral Fellow, Guo-Cheng Yuan's lab
Department of Pediatric Oncology
Dana-Farber Cancer Institute
360 Longwood Ave, Boston, MA, 02215


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

* Re: Fwd: sshfs crash with zsh
  2020-08-12 10:13 ` Fwd: sshfs crash with zsh Peter Stephenson
@ 2020-08-12 15:55   ` Phil Pennock
  2020-08-12 17:50     ` Rui Dong
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Pennock @ 2020-08-12 15:55 UTC (permalink / raw)
  To: rdong1989; +Cc: zsh-user

On 2020-08-12 at 01:25, Rui Dong wrote:
> I am a fan of zsh, and used it for many years. Recently I found when I
> configure the server with zsh, I could not mount the disk with sshfs. If I
> comment the "exec /bin/zsh --login" out, sshfs works again. Could you
> please help with this?

It sounds like you're trying to change your shell in user configuration
files without changing the login user's shell in the system records.
And then you're doing this in a configuration file used for all logins,
even non-interactive ones.

So when some other command tries to log in, your shell switch is
happening and discarding the actual commands to be run.

You probably want to use the `chsh` command to change the shell instead.
Or `vipw` or whatever else changes the shell in the `/etc/passwd` file:
the last field on the line for your user specifies the shell.

If you _have_ to use configuration files, then make sure that you only
change shells, or run any command which produces output to stdout or
stderr, if the shell is interactive.

How you do that depends upon the shell which is being used, and which
configuration file you edit.  Check the manual-page for guidance on
which file to be edited.

If one configuration file is used for both interactive and
non-interactive use, and there's no other file you can use, then you can
use conditional logic to wrap around the exec and only call that when
interactive.  The syntax depends upon the shell (csh, bash, whatever).
There are two traditional approaches for "what to test":

1. You can look at $PS1, as long as nothing is polluting the environment
   by exporting it: PS1 will only be set by shells when the shell is
   interactive, because this is the main variable used to define what
   your command prompt looks like.  But sloppy practices (exporting PS1)
   will ruin this.
2. The shell might have a variable which lists which options are in
   effect, and you can check for the interactive option in that.  For
   instance, with the bash shell, you might check for `i` in `$-`:

    if [[ $- == *i* ]]; then
      exec /bin/zsh --login
    fi

More than that, we can't help you with, as there are too few details in
your mail about your setup.

Regards,
-Phil


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

* Re: Fwd: sshfs crash with zsh
  2020-08-12 15:55   ` Phil Pennock
@ 2020-08-12 17:50     ` Rui Dong
  0 siblings, 0 replies; 3+ messages in thread
From: Rui Dong @ 2020-08-12 17:50 UTC (permalink / raw)
  To: Phil Pennock; +Cc: zsh-user

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

Hi Phil,

Thanks for the info. Your response really helps. I am sorry for the limited
information I provided. The zsh was started from bashrc file because I have
no root permission in the server. With your help, I solved the problem by
checking for 'i' in '$-'.
Thank you so much.

Best,
Rui

Phil Pennock <zsh-workers+phil.pennock@spodhuis.org> 于2020年8月12日周三
上午11:55写道:

> On 2020-08-12 at 01:25, Rui Dong wrote:
> > I am a fan of zsh, and used it for many years. Recently I found when I
> > configure the server with zsh, I could not mount the disk with sshfs. If
> I
> > comment the "exec /bin/zsh --login" out, sshfs works again. Could you
> > please help with this?
>
> It sounds like you're trying to change your shell in user configuration
> files without changing the login user's shell in the system records.
> And then you're doing this in a configuration file used for all logins,
> even non-interactive ones.
>
> So when some other command tries to log in, your shell switch is
> happening and discarding the actual commands to be run.
>
> You probably want to use the `chsh` command to change the shell instead.
> Or `vipw` or whatever else changes the shell in the `/etc/passwd` file:
> the last field on the line for your user specifies the shell.
>
> If you _have_ to use configuration files, then make sure that you only
> change shells, or run any command which produces output to stdout or
> stderr, if the shell is interactive.
>
> How you do that depends upon the shell which is being used, and which
> configuration file you edit.  Check the manual-page for guidance on
> which file to be edited.
>
> If one configuration file is used for both interactive and
> non-interactive use, and there's no other file you can use, then you can
> use conditional logic to wrap around the exec and only call that when
> interactive.  The syntax depends upon the shell (csh, bash, whatever).
> There are two traditional approaches for "what to test":
>
> 1. You can look at $PS1, as long as nothing is polluting the environment
>    by exporting it: PS1 will only be set by shells when the shell is
>    interactive, because this is the main variable used to define what
>    your command prompt looks like.  But sloppy practices (exporting PS1)
>    will ruin this.
> 2. The shell might have a variable which lists which options are in
>    effect, and you can check for the interactive option in that.  For
>    instance, with the bash shell, you might check for `i` in `$-`:
>
>     if [[ $- == *i* ]]; then
>       exec /bin/zsh --login
>     fi
>
> More than that, we can't help you with, as there are too few details in
> your mail about your setup.
>
> Regards,
> -Phil
>


-- 
Rui Dong
Postdoctoral Fellow, Guo-Cheng Yuan's lab
Department of Pediatric Oncology
Dana-Farber Cancer Institute
360 Longwood Ave, Boston, MA, 02215

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

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

end of thread, other threads:[~2020-08-12 18:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAAg1DCMTC7tk-uTN0Twvj3pGeJRz_-3mpL6m-YrO-5cMXjsbow@mail.gmail.com>
2020-08-12 10:13 ` Fwd: sshfs crash with zsh Peter Stephenson
2020-08-12 15:55   ` Phil Pennock
2020-08-12 17:50     ` Rui Dong

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ http://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git