summaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-04-06 21:51:31 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-04-06 21:51:31 +0000
commitec89eb955236f91e63febe1764123e605641fc52 (patch)
treec81e8a37c4625857f084ffdf70efba82fe715df3 /cmd.c
parentc8a14def9f2273c13d081c891d76e5f32323fc40 (diff)
Change so that an empty session name always means the current sessions
even if given with, for example, -t '', and explicitly forbid empty session names and those containing a : when they are created.
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/cmd.c b/cmd.c
index ac66f6e8..ee893a25 100644
--- a/cmd.c
+++ b/cmd.c
@@ -725,6 +725,12 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached)
if (arglen != 0 && tmparg[arglen - 1] == ':')
tmparg[arglen - 1] = '\0';
+ /* An empty session name is the current session. */
+ if (*tmparg == '\0') {
+ xfree (tmparg);
+ return (cmd_current_session(ctx, prefer_unattached));
+ }
+
/* Find the session, if any. */
s = cmd_lookup_session(tmparg, &ambiguous);
@@ -840,7 +846,7 @@ no_colon:
lookup_session:
if (ambiguous)
goto not_found;
- if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)
+ if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL)
goto no_session;
if (sp != NULL)
@@ -981,7 +987,7 @@ no_colon:
lookup_session:
if (ambiguous)
goto not_found;
- if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)
+ if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL)
goto no_session;
if (sp != NULL)