Bug 36685 - annoying warnings from mc with tcsh in home dir
Summary: annoying warnings from mc with tcsh in home dir
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Max Khon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-03 04:30 UTC by Andriy Gapon
Modified: 2002-10-23 23:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Gapon 2002-04-03 04:30:01 UTC
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
Comment 1 dwcjr 2002-04-04 05:51:25 UTC
I can verify this problem as well.
Comment 2 Tilman Keskinoz freebsd_committer freebsd_triage 2002-10-20 17:50:15 UTC
Responsible Changed
From-To: freebsd-ports->fjoe

mc is maintained by fjoe
Comment 3 Max Khon freebsd_committer freebsd_triage 2002-10-20 20:09:35 UTC
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
Comment 4 Max Khon freebsd_committer freebsd_triage 2002-10-20 20:51:24 UTC
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
Comment 5 Max Khon freebsd_committer freebsd_triage 2002-10-23 23:10:08 UTC
State Changed
From-To: open->closed

patch added to ports/misc/mc