summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2009-12-20 00:14:15 -0500
committerSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2009-12-20 00:14:15 -0500
commit4b778782ce398747f080b7b7ffd8a2e26c3b0a88 (patch)
tree1dec4bbeba6bd735961ec4cdfaabdeecba266284
parent90afd2d35d8cff7a403dcaf71d3f2fd4857f9994 (diff)
downloadscreen-4b778782ce398747f080b7b7ffd8a2e26c3b0a88.tar.gz
Allow 'at' command for windows without a display.
For window-context, 'at' commands can work without any existing display. So allow for that. If the command specified for 'at' requires a display, then that will still fail, as it should. But for some commands, just an existing window is enough. Fixes savannah bug #26996.
-rw-r--r--src/comm.c2
-rw-r--r--src/process.c30
2 files changed, 21 insertions, 11 deletions
diff --git a/src/comm.c b/src/comm.c
index 4e3787e..883c99a 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -58,7 +58,7 @@ struct comm comms[RC_LAST + 1] =
#endif
{ "allpartial", NEED_DISPLAY|ARGS_1 },
{ "altscreen", ARGS_01 },
- { "at", NEED_DISPLAY|ARGS_2|ARGS_ORMORE },
+ { "at", ARGS_2|ARGS_ORMORE },
#ifdef COLOR
{ "attrcolor", ARGS_12 },
#endif
diff --git a/src/process.c b/src/process.c
index 76785e1..70bb4fa 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1451,12 +1451,14 @@ int key;
break;
case RC_AT:
/* where this AT command comes from: */
+ if (!user)
+ break;
#ifdef MULTIUSER
- s = SaveStr(D_user->u_name);
+ s = SaveStr(user->u_name);
/* DO NOT RETURN FROM HERE WITHOUT RESETTING THIS: */
- EffectiveAclUser = D_user;
+ EffectiveAclUser = user;
#else
- s = SaveStr(D_usertty);
+ s = SaveStr(display ? D_usertty : user->u_name);
#endif
n = strlen(args[0]);
if (n) n--;
@@ -1473,14 +1475,22 @@ int key;
struct acluser *u;
if (!n)
- u = D_user;
+ u = user;
else
- for (u = users; u; u = u->u_next)
- {
- debug3("strncmp('%s', '%s', %d)\n", *args, u->u_name, n);
- if (!strncmp(*args, u->u_name, n))
+ {
+ for (u = users; u; u = u->u_next)
+ {
+ debug3("strncmp('%s', '%s', %d)\n", *args, u->u_name, n);
+ if (!strncmp(*args, u->u_name, n))
+ break;
+ }
+ if (!u)
+ {
+ args[0][n] = '\0';
+ Msg(0, "Did not find any user matching '%s'", args[0]);
break;
- }
+ }
+ }
debug1("at all displays of user %s\n", u->u_name);
for (display = displays; display; display = nd)
{
@@ -1539,7 +1549,7 @@ int key;
struct win *nw;
int ch;
- n++;
+ n++;
ch = args[0][n];
args[0][n] = '\0';
if (!*args[0] || (i = WindowByNumber(args[0])) < 0)