summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-01-04 23:56:46 +0100
committerSebastien Helleu <flashcode@flashtux.org>2011-01-04 23:56:46 +0100
commit3cd267ab23ff25c89204cb5be0f019c1254ac83f (patch)
tree13f5bed41f19612c709186893a7b9ce499134ea5 /src/core/wee-command.c
parent57102fef706ea80364c73379aca802b1f7bdc67d (diff)
downloadweechat-3cd267ab23ff25c89204cb5be0f019c1254ac83f.zip
Fix bug with /upgrade: check existence of binary even when command is executed without argument
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index d6ab14857..5852b99e2 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -3721,35 +3721,7 @@ COMMAND_CALLBACK(upgrade)
}
if (argc > 1)
- {
ptr_binary = string_expand_home (argv_eol[1]);
- if (ptr_binary)
- {
- /* check if weechat binary is here and executable by user */
- rc = stat (ptr_binary, &stat_buf);
- if ((rc != 0) || (!S_ISREG(stat_buf.st_mode)))
- {
- gui_chat_printf (NULL,
- _("%sCan't upgrade: WeeChat binary \"%s\" "
- "does not exist"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- ptr_binary);
- free (ptr_binary);
- return WEECHAT_RC_OK;
- }
- if ((!(stat_buf.st_mode & S_IXUSR)) && (!(stat_buf.st_mode & S_IXGRP))
- && (!(stat_buf.st_mode & S_IXOTH)))
- {
- gui_chat_printf (NULL,
- _("%sCan't upgrade: WeeChat binary \"%s\" "
- "does not have execute permissions"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- ptr_binary);
- free (ptr_binary);
- return WEECHAT_RC_OK;
- }
- }
- }
else
ptr_binary = strdup (weechat_argv0);
@@ -3761,6 +3733,30 @@ COMMAND_CALLBACK(upgrade)
return WEECHAT_RC_OK;
}
+ /* check if weechat binary is here and executable by user */
+ rc = stat (ptr_binary, &stat_buf);
+ if ((rc != 0) || (!S_ISREG(stat_buf.st_mode)))
+ {
+ gui_chat_printf (NULL,
+ _("%sCan't upgrade: WeeChat binary \"%s\" "
+ "does not exist"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ ptr_binary);
+ free (ptr_binary);
+ return WEECHAT_RC_OK;
+ }
+ if ((!(stat_buf.st_mode & S_IXUSR)) && (!(stat_buf.st_mode & S_IXGRP))
+ && (!(stat_buf.st_mode & S_IXOTH)))
+ {
+ gui_chat_printf (NULL,
+ _("%sCan't upgrade: WeeChat binary \"%s\" "
+ "does not have execute permissions"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ ptr_binary);
+ free (ptr_binary);
+ return WEECHAT_RC_OK;
+ }
+
gui_chat_printf (NULL,
_("Upgrading WeeChat with binary file: \"%s\"..."),
ptr_binary);