@@ -145,7 +145,6 @@ static char *arg_root = NULL;
145145static usec_t arg_when = 0 ;
146146static char * argv_cmdline = NULL ;
147147static enum action {
148- _ACTION_INVALID ,
149148 ACTION_SYSTEMCTL ,
150149 ACTION_HALT ,
151150 ACTION_POWEROFF ,
@@ -166,7 +165,8 @@ static enum action {
166165 ACTION_REEXEC ,
167166 ACTION_RUNLEVEL ,
168167 ACTION_CANCEL_SHUTDOWN ,
169- _ACTION_MAX
168+ _ACTION_MAX ,
169+ _ACTION_INVALID = -1
170170} arg_action = ACTION_SYSTEMCTL ;
171171static BusTransport arg_transport = BUS_TRANSPORT_LOCAL ;
172172static const char * arg_host = NULL ;
@@ -3052,7 +3052,7 @@ static const struct {
30523052static enum action verb_to_action (const char * verb ) {
30533053 enum action i ;
30543054
3055- for (i = _ACTION_INVALID ; i < _ACTION_MAX ; i ++ )
3055+ for (i = 0 ; i < _ACTION_MAX ; i ++ )
30563056 if (streq_ptr (action_table [i ].verb , verb ))
30573057 return i ;
30583058
@@ -3068,8 +3068,8 @@ static int start_unit(int argc, char *argv[], void *userdata) {
30683068 char * * name ;
30693069 int r = 0 ;
30703070
3071- if (arg_wait && !strstr (argv [0 ], "start" )) {
3072- log_error ("--wait may only be used with a command that starts units ." );
3071+ if (arg_wait && !STR_IN_SET (argv [0 ], "start" , "restart " )) {
3072+ log_error ("--wait may only be used with the 'start' or 'restart' commands ." );
30733073 return - EINVAL ;
30743074 }
30753075
@@ -3085,22 +3085,30 @@ static int start_unit(int argc, char *argv[], void *userdata) {
30853085 if (arg_action == ACTION_SYSTEMCTL ) {
30863086 enum action action ;
30873087
3088- method = verb_to_method (argv [0 ]);
30893088 action = verb_to_action (argv [0 ]);
30903089
3091- if (streq (argv [0 ], "isolate" )) {
3092- mode = "isolate" ;
3093- suffix = ".target" ;
3094- } else
3095- mode = action_table [action ].mode ?: arg_job_mode ;
3090+ if (action != _ACTION_INVALID ) {
3091+ method = "StartUnit" ;
3092+ mode = action_table [action ].mode ;
3093+ one_name = action_table [action ].target ;
3094+ } else {
3095+ if (streq (argv [0 ], "isolate" )) {
3096+ method = "StartUnit" ;
3097+ mode = "isolate" ;
30963098
3097- one_name = action_table [action ].target ;
3099+ suffix = ".target" ;
3100+ } else {
3101+ method = verb_to_method (argv [0 ]);
3102+ mode = arg_job_mode ;
3103+ }
3104+ one_name = NULL ;
3105+ }
30983106 } else {
30993107 assert (arg_action < ELEMENTSOF (action_table ));
31003108 assert (action_table [arg_action ].target );
3109+ assert (action_table [arg_action ].mode );
31013110
31023111 method = "StartUnit" ;
3103-
31043112 mode = action_table [arg_action ].mode ;
31053113 one_name = action_table [arg_action ].target ;
31063114 }
0 commit comments