summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2010-02-16 13:37:39 -0500
committerSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2010-02-16 13:41:20 -0500
commita889d858d6baae4d6bc2da98bf6ee82e52ad5fbc (patch)
tree09d4f42ff2f6fc825283f6b941b528a10d392448
parent6c6d7edccebb2c33abbf461299f2cea99ecb1a17 (diff)
downloadscreen-a889d858d6baae4d6bc2da98bf6ee82e52ad5fbc.tar.gz
Error out if a pre-select window is not found.
The man-page is updated to show that if the window selected using '-p' cannot be determined with -X or -Q flags, then the command specified will not be executed. Fixes #28783 in savannah.
-rw-r--r--src/doc/screen.13
-rw-r--r--src/doc/screen.texinfo3
-rw-r--r--src/socket.c18
3 files changed, 17 insertions, 7 deletions
diff --git a/src/doc/screen.1 b/src/doc/screen.1
index afee22b..b580b45 100644
--- a/src/doc/screen.1
+++ b/src/doc/screen.1
@@ -293,7 +293,8 @@ Preselect a window. This is useful when you want to reattach to a
specific window or you want to send a command via the \*Q-X\*U
option to a specific window. As with screen's select command, \*Q-\*U
selects the blank window. As a special case for reattach, \*Q=\*U
-brings up the windowlist on the blank window.
+brings up the windowlist on the blank window. The command will not be
+executed if the specified window could not be found.
.TP 5
.B \-q
Suppress printing of error messages. In combination with \*Q-ls\*U the exit
diff --git a/src/doc/screen.texinfo b/src/doc/screen.texinfo
index 2bdc775..5941523 100644
--- a/src/doc/screen.texinfo
+++ b/src/doc/screen.texinfo
@@ -362,7 +362,8 @@ specific window or you want to send a command via the @samp{-X}
option to a specific window. As with screen's select command, @samp{-}
selects the blank window. As a special case for reattach, @samp{=}
brings up the windowlist on the blank window, while a @samp{+} will
-create new window.
+create new window. The command will not be executed if the specified
+window could not be found.
@item -q
Suppress printing of error messages. In combination with @samp{-ls} the exit
diff --git a/src/socket.c b/src/socket.c
index 70b57db..9e90564 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1653,7 +1653,7 @@ struct msg *mp;
*--fc = 0;
if (Parse(fullcmd, fc - fullcmd, args, argl) <= 0)
{
- /* XXX: Return some useful message back if MSG_QUERY */
+ queryflag = -1;
return;
}
#ifdef MULTIUSER
@@ -1661,7 +1661,7 @@ struct msg *mp;
if (user == 0)
{
Msg(0, "Unknown user %s tried to send a command!", mp->m.attach.auser);
- /* XXX: Return some useful message back if MSG_QUERY */
+ queryflag = -1;
return;
}
#else
@@ -1670,8 +1670,8 @@ struct msg *mp;
#ifdef PASSWORD
if (user->u_password && *user->u_password)
{
- Msg(0, "User %s has a password, cannot use -X option.", mp->m.attach.auser);
- /* XXX: Return some useful message back if MSG_QUERY */
+ Msg(0, "User %s has a password, cannot use remote commands (using -Q or -X option).", mp->m.attach.auser);
+ queryflag = -1;
return;
}
#endif
@@ -1692,7 +1692,15 @@ struct msg *mp;
{
int i = -1;
if (strcmp(mp->m.command.preselect, "-"))
- i = WindowByNoN(mp->m.command.preselect);
+ {
+ i = WindowByNoN(mp->m.command.preselect);
+ if (i < 0 || !wtab[i])
+ {
+ Msg(0, "Could not find pre-select window.");
+ queryflag = -1;
+ return;
+ }
+ }
fore = i >= 0 ? wtab[i] : 0;
}
else if (!fore)