[RFC] Don't abort when chdir'ing to a relative path

Davide "FunkyAss" Del Zompo davide.delzompo at gmail.com
Wed Jul 29 22:55:50 CEST 2015


---

Hello everybody, why does rxvt-unicode abort when a relative path is
given to the -cd switch?

I tried to investigate on my own asking on irc and inspecting the log
from the github mirror (I'm not familiar with cvs, so maybe I missed
some informations) but I found nothing explaining the current behaviour.

The following patch is meant for better explaining what I was expecting
instead of what i found. Please keep in mind that I'm not familiar with
the code base, so I could have missed something important.

 src/init.C | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/init.C b/src/init.C
index 2b15590..126dd1c 100644
--- a/src/init.C
+++ b/src/init.C
@@ -795,15 +795,9 @@ rxvt_term::init2 (int argc, const char *const *argv)
   keyboard->register_done ();
 #endif
 
-  if (const char *path = rs[Rs_chdir])
-    if (*path) // ignored if empty
-      {
-        if (*path != '/')
-          rxvt_fatal ("specified shell working directory must start with a slash, aborting.\n");
-
-        if (chdir (path))
-          rxvt_fatal ("unable to change into specified shell working directory, aborting.\n");
-      }
+  // don't chdir if path is empty
+  if (const char *path = rs[Rs_chdir] && *path && chdir (path))
+      rxvt_fatal ("unable to change into specified shell working directory, aborting.\n");
 
   if (option (Opt_scrollBar))
     scrollBar.state = SB_STATE_IDLE;    /* set existence for size calculations */
-- 
2.5.0




More information about the rxvt-unicode mailing list