From nobody@FreeBSD.org  Tue Apr  2 19:25:19 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 6B44237B421
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  2 Apr 2002 19:25:18 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g333PFQ05661;
	Tue, 2 Apr 2002 19:25:15 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200204030325.g333PFQ05661@freefall.freebsd.org>
Date: Tue, 2 Apr 2002 19:25:15 -0800 (PST)
From: Andriy Gapon <avg@icyb.net.ua>
To: freebsd-gnats-submit@FreeBSD.org
Subject: annoying warnings from mc with tcsh in home dir
X-Send-Pr-Version: www-1.0

>Number:         36685
>Category:       ports
>Synopsis:       annoying warnings from mc with tcsh in home dir
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    fjoe
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 02 19:30:01 PST 2002
>Closed-Date:    Wed Oct 23 15:10:48 PDT 2002
>Last-Modified:  Wed Oct 23 15:10:48 PDT 2002
>Originator:     Andriy Gapon
>Release:        FreeBSD 4.5
>Organization:
>Environment:
FreeBSD edge.icyb.net 4.5-RELEASE-p1 FreeBSD 4.5-RELEASE-p1 #0: Mon Feb 25 23:52:47 EST 2002     avg@edge.icyb.net:/sys-devel/obj/sys-devel/src/sys/EDGE  i386

>Description:
source of problem lies in special handling of user's home directory by tcsh: if symlinks is unset, cwd is set to /home/<homedirname> even if the latter is actually a link to /usr/home/<homedirname> and you cd to that.

501/home/avg
p4:edge-22:10>cd /usr/home/avg/
502/home/avg
p4:edge-22:10>echo $cwd
/home/avg
503/home/avg
p4:edge-22:10>cd /
504/
p4:edge-22:11>cd usr
505/usr
p4:edge-22:11>cd home
506/usr/home
p4:edge-22:11>cd avg
507/home/avg
p4:edge-22:11>echo $cwd
/home/avg

so if user changes to his dir through directory hierarchy, a name of dir expected by MC (and confirmed with call to getwd()) will differ from current work dir name reported by subshell (which is determined via cwd) and will result in annoying warning messages. 
>How-To-Repeat:
have MC with subshell enabled and have tcsh as your shell
have a standard FreeBSD location of your home dir in /usr/home and have a coventional link /home --> /usr/home
in one of the panels cd to /
using MC's "GUI" cd to /usr, /usr/home, /usr/home/<your_home_dir>

MC should produce warning about being unable to cd

>Fix:
      
>Release-Note:
>Audit-Trail:

From: "David W. Chapman Jr." <dwcjr@inethouston.net>
To: freebsd-gnats-submit@FreeBSD.org, avg@icyb.net.ua
Cc:  
Subject: Re: ports/36685: annoying warnings from mc with tcsh in home dir
Date: Wed, 03 Apr 2002 22:51:25 -0600

 I can verify this problem as well.
 
Responsible-Changed-From-To: freebsd-ports->fjoe 
Responsible-Changed-By: arved 
Responsible-Changed-When: Sun Oct 20 09:50:15 PDT 2002 
Responsible-Changed-Why:  
mc is maintained by fjoe 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36685 

From: Max Khon <fjoe@FreeBSD.org>
To: Tilman Linneweh <arved@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/36685: annoying warnings from mc with tcsh in home dir
Date: Sun, 20 Oct 2002 12:09:35 -0700

 hi, there!
 
 please try this patch (which is mostly a hack)
 
 --- src/subshell.c.orig	Mon Oct 21 01:43:29 2002
 +++ src/subshell.c	Mon Oct 21 01:47:17 2002
 @@ -852,6 +852,9 @@
  /* If it actually changed the directory it returns true */
  void do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
  {
 +    char buf[PATH_MAX];
 +    int n;
 +
      if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, cpanel->cwd))){
  	/* We have to repaint the subshell prompt if we read it from
  	 * the main program.  Please note that in the code after this
 @@ -878,7 +881,11 @@
      subshell_state = RUNNING_COMMAND;
      feed_subshell (QUIETLY, FALSE);
      
 -    if (subshell_alive && strcmp (subshell_cwd, cpanel->cwd) && strcmp (cpanel->cwd, "."))
 +    if (subshell_alive && strcmp (subshell_cwd, cpanel->cwd)
 +    &&  (subshell_type == TCSH &&
 +	 (n = readlink(subshell_cwd, buf, sizeof(buf))) >= 0 &&
 +         (buf[n] = '\0', strcmp(buf, cpanel->cwd)))
 +    &&  strcmp (cpanel->cwd, "."))
  	fprintf (stderr, _("Warning: Couldn't change to %s.\n"), cpanel->cwd);
  
      if (reset_prompt)
 
 /fjoe

From: Max Khon <fjoe@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/36685: annoying warnings from mc with tcsh in home dir
Date: Sun, 20 Oct 2002 12:51:24 -0700

 hi, there!
 
 ugh, wrong patch. try this one
 
 --- src/subshell.c.orig	Mon Oct 21 01:43:29 2002
 +++ src/subshell.c	Mon Oct 21 02:37:56 2002
 @@ -852,6 +852,8 @@
  /* If it actually changed the directory it returns true */
  void do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
  {
 +    char buf[MAXPATHLEN];
 +
      if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, cpanel->cwd))){
  	/* We have to repaint the subshell prompt if we read it from
  	 * the main program.  Please note that in the code after this
 @@ -878,7 +880,12 @@
      subshell_state = RUNNING_COMMAND;
      feed_subshell (QUIETLY, FALSE);
      
 -    if (subshell_alive && strcmp (subshell_cwd, cpanel->cwd) && strcmp (cpanel->cwd, "."))
 +    if (subshell_alive
 +    && strcmp (subshell_cwd, cpanel->cwd)
 +    && strcmp (cpanel->cwd, ".")
 +    && (subshell_type != TCSH ||
 +      realpath (subshell_cwd, buf) == NULL ||
 +      strcmp (cpanel->cwd, buf)))
  	fprintf (stderr, _("Warning: Couldn't change to %s.\n"), cpanel->cwd);
  
      if (reset_prompt)
 
 /fjoe
State-Changed-From-To: open->closed 
State-Changed-By: fjoe 
State-Changed-When: Wed Oct 23 15:10:08 PDT 2002 
State-Changed-Why:  
patch added to ports/misc/mc 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36685 
>Unformatted:
