@@ -0,0 +1,110 @@
1+diff --git a/src/core/wee-command.c b/src/core/wee-command.c
2+index 91c3c068d..8105e4171 100644
3+--- a/src/core/wee-command.c
4++++ b/src/core/wee-command.c
5+@@ -8345,10 +8345,20 @@ command_exec_list (const char *command_list)
6+ void
7+ command_startup (int plugins_loaded)
8+ {
9++ int i;
10++
11+ if (plugins_loaded)
12+ {
13+ command_exec_list (CONFIG_STRING(config_startup_command_after_plugins));
14+- command_exec_list (weechat_startup_commands);
15++ if (weechat_startup_commands)
16++ {
17++ for (i = 0; i < weelist_size (weechat_startup_commands); i++)
18++ {
19++ command_exec_list (
20++ weelist_string (
21++ weelist_get (weechat_startup_commands, i)));
22++ }
23++ }
24+ }
25+ else
26+ command_exec_list (CONFIG_STRING(config_startup_command_before_plugins));
27+diff --git a/src/core/weechat.c b/src/core/weechat.c
28+index f74598ad5..ff2e539d1 100644
29+--- a/src/core/weechat.c
30++++ b/src/core/weechat.c
31+@@ -60,6 +60,7 @@
32+ #include "wee-eval.h"
33+ #include "wee-hdata.h"
34+ #include "wee-hook.h"
35++#include "wee-list.h"
36+ #include "wee-log.h"
37+ #include "wee-network.h"
38+ #include "wee-proxy.h"
39+@@ -102,7 +103,8 @@ int weechat_no_gnutls = 0; /* remove init/deinit of gnutls */
40+ /* (useful with valgrind/electric-f.)*/
41+ int weechat_no_gcrypt = 0; /* remove init/deinit of gcrypt */
42+ /* (useful with valgrind) */
43+-char *weechat_startup_commands = NULL; /* startup commands (-r flag) */
44++struct t_weelist *weechat_startup_commands = NULL; /* startup commands */
45++ /* (option -r) */
46+
47+
48+ /*
49+@@ -152,9 +154,13 @@ weechat_display_usage ()
50+ " -h, --help display this help\n"
51+ " -l, --license display WeeChat license\n"
52+ " -p, --no-plugin don't load any plugin at startup\n"
53+- " -r, --run-command <cmd> run command(s) after startup\n"
54+- " (many commands can be separated by "
55+- "semicolons)\n"
56++ " -P, --plugins <plugins> load only these plugins at startup\n"
57++ " (see /help weechat.plugin.autoload)\n"
58++ " -r, --run-command <cmd> run command(s) after startup;\n"
59++ " many commands can be separated by "
60++ "semicolons,\n"
61++ " this option can be given multiple "
62++ "times\n"
63+ " -s, --no-script don't load any script at startup\n"
64+ " --upgrade upgrade WeeChat using session files "
65+ "(see /help upgrade in WeeChat)\n"
66+@@ -276,9 +282,10 @@ weechat_parse_args (int argc, char *argv[])
67+ {
68+ if (i + 1 < argc)
69+ {
70+- if (weechat_startup_commands)
71+- free (weechat_startup_commands);
72+- weechat_startup_commands = strdup (argv[++i]);
73++ if (!weechat_startup_commands)
74++ weechat_startup_commands = weelist_new ();
75++ weelist_add (weechat_startup_commands, argv[++i],
76++ WEECHAT_LIST_POS_END, NULL);
77+ }
78+ else
79+ {
80+@@ -616,6 +623,8 @@ weechat_shutdown (int return_code, int crash)
81+ free (weechat_home);
82+ if (weechat_local_charset)
83+ free (weechat_local_charset);
84++ if (weechat_startup_commands)
85++ weelist_free (weechat_startup_commands);
86+
87+ if (crash)
88+ abort ();
89+diff --git a/src/core/weechat.h b/src/core/weechat.h
90+index 9420ff415..cbb565a03 100644
91+--- a/src/core/weechat.h
92++++ b/src/core/weechat.h
93+@@ -96,6 +96,8 @@
94+ /* name of environment variable with an extra lib dir */
95+ #define WEECHAT_EXTRA_LIBDIR "WEECHAT_EXTRA_LIBDIR"
96+
97++struct t_weelist;
98++
99+ /* global variables and functions */
100+ extern int weechat_headless;
101+ extern int weechat_debug_core;
102+@@ -112,7 +114,7 @@ extern char *weechat_local_charset;
103+ extern int weechat_plugin_no_dlclose;
104+ extern int weechat_no_gnutls;
105+ extern int weechat_no_gcrypt;
106+-extern char *weechat_startup_commands;
107++extern struct t_weelist *weechat_startup_commands;
108+
109+ extern void weechat_term_check ();
110+ extern void weechat_shutdown (int return_code, int crash);