aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-02-17 21:57:57 +0100
committerBoris Faure <billiob@gmail.com>2017-02-17 21:57:57 +0100
commite188244c720097aa682a28147081ebdc4b924507 (patch)
treeced05762ae8885fa60a2f4ec564c3af36256d662
parentwin: double click on tab title to change it. Closes T3143 (diff)
downloadterminology-e188244c720097aa682a28147081ebdc4b924507.tar.gz
pty: fallback to ~ or / when creating new term if current dir is not available
-rw-r--r--src/bin/termpty.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 30ee96a..9fb7615 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -575,14 +575,34 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
if (!ty->pid)
{
char buf[256];
+ int ret;
if (cd)
{
- if (chdir(cd) != 0)
+ ret = chdir(cd);
+ if (ret != 0)
{
ERR(_("Could not change current directory to '%s': %s"),
cd, strerror(errno));
- exit(127);
+ cd = getenv("HOME");
+ if (cd)
+ {
+ ret = chdir(cd);
+ if (ret != 0)
+ {
+ ERR(_("Could not change current directory to '%s': %s"),
+ cd, strerror(errno));
+ }
+ }
+ if (ret != 0)
+ {
+ cd = "/";
+ if (chdir(cd) != 0)
+ {
+ ERR(_("Could not change current directory to '%s': %s"),
+ cd, strerror(errno));
+ }
+ }
}
}