mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Handle empty current directory more gracefully.
This commit is contained in:
parent
72a4602b88
commit
7aeb4473ad
@ -107,13 +107,16 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
cp = format_expand(ft, args_get(args, 'c'));
|
cp = format_expand(ft, args_get(args, 'c'));
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
if (cp != NULL && *cp != '\0') {
|
||||||
free(cp);
|
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||||
if (fd == -1) {
|
free(cp);
|
||||||
cmdq_error(cmdq, "bad working directory: %s",
|
if (fd == -1) {
|
||||||
strerror(errno));
|
cmdq_error(cmdq, "bad working directory: %s",
|
||||||
return (CMD_RETURN_ERROR);
|
strerror(errno));
|
||||||
}
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
} else if (cp != NULL)
|
||||||
|
free(cp);
|
||||||
cwd = fd;
|
cwd = fd;
|
||||||
} else if (c != NULL && c->session == NULL)
|
} else if (c != NULL && c->session == NULL)
|
||||||
cwd = c->cwd;
|
cwd = c->cwd;
|
||||||
|
@ -117,13 +117,16 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
cp = format_expand(ft, args_get(args, 'c'));
|
cp = format_expand(ft, args_get(args, 'c'));
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
if (cp != NULL && *cp != '\0') {
|
||||||
free(cp);
|
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||||
if (fd == -1) {
|
free(cp);
|
||||||
cmdq_error(cmdq, "bad working directory: %s",
|
if (fd == -1) {
|
||||||
strerror(errno));
|
cmdq_error(cmdq, "bad working directory: %s",
|
||||||
return (CMD_RETURN_ERROR);
|
strerror(errno));
|
||||||
}
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
} else if (cp != NULL)
|
||||||
|
free(cp);
|
||||||
cwd = fd;
|
cwd = fd;
|
||||||
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||||
cwd = cmdq->client->cwd;
|
cwd = cmdq->client->cwd;
|
||||||
|
@ -95,13 +95,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
cp = format_expand(ft, args_get(args, 'c'));
|
cp = format_expand(ft, args_get(args, 'c'));
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|
||||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
if (cp != NULL && *cp != '\0') {
|
||||||
free(cp);
|
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||||
if (fd == -1) {
|
free(cp);
|
||||||
cmdq_error(cmdq, "bad working directory: %s",
|
if (fd == -1) {
|
||||||
strerror(errno));
|
cmdq_error(cmdq, "bad working directory: %s",
|
||||||
return (CMD_RETURN_ERROR);
|
strerror(errno));
|
||||||
}
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
} else if (cp != NULL)
|
||||||
|
free(cp);
|
||||||
cwd = fd;
|
cwd = fd;
|
||||||
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||||
cwd = cmdq->client->cwd;
|
cwd = cmdq->client->cwd;
|
||||||
|
Loading…
Reference in New Issue
Block a user