File src/background.c changed (mode: 100644) (index d8df9f6af..3cb5d900f) |
27 |
27 |
#include <fcntl.h> |
#include <fcntl.h> |
28 |
28 |
|
|
29 |
29 |
#include "background.h" |
#include "background.h" |
|
30 |
|
#include "commands.h" |
30 |
31 |
#include "config.h" |
#include "config.h" |
31 |
32 |
#include "menus.h" |
#include "menus.h" |
32 |
33 |
#include "status.h" |
#include "status.h" |
|
... |
... |
add_finished_job(pid_t pid, int status) |
59 |
60 |
new->pid = pid; |
new->pid = pid; |
60 |
61 |
new->remove = 0; |
new->remove = 0; |
61 |
62 |
new->next = fjobs; |
new->next = fjobs; |
|
63 |
|
new->exit_code = WEXITSTATUS(status); |
62 |
64 |
fjobs = new; |
fjobs = new; |
63 |
65 |
} |
} |
64 |
66 |
|
|
|
... |
... |
check_background_jobs(void) |
99 |
101 |
{ |
{ |
100 |
102 |
p->running = 0; |
p->running = 0; |
101 |
103 |
fj->remove = 1; |
fj->remove = 1; |
|
104 |
|
p->exit_code = fj->exit_code; |
102 |
105 |
} |
} |
103 |
106 |
fj = fj->next; |
fj = fj->next; |
104 |
107 |
} |
} |
|
... |
... |
check_background_jobs(void) |
124 |
127 |
} |
} |
125 |
128 |
if (strlen(p->error_buf) > 1) |
if (strlen(p->error_buf) > 1) |
126 |
129 |
{ |
{ |
127 |
|
show_error_msg("Background Process Error", p->error_buf); |
|
128 |
|
free(p->error_buf); |
|
129 |
|
p->error_buf = (char *) calloc(1, sizeof(char)); |
|
|
130 |
|
if (!p->running && p->exit_code == 127 && curr_stats.fast_run) |
|
131 |
|
{ |
|
132 |
|
char *buf = fast_run_complete(p->cmd); |
|
133 |
|
if(buf == NULL) |
|
134 |
|
curr_stats.save_msg = 1; |
|
135 |
|
else |
|
136 |
|
start_background_job(buf); |
|
137 |
|
} |
|
138 |
|
else |
|
139 |
|
{ |
|
140 |
|
show_error_msg("Background Process Error", p->error_buf); |
|
141 |
|
free(p->error_buf); |
|
142 |
|
p->error_buf = (char *) calloc(1, sizeof(char)); |
|
143 |
|
} |
130 |
144 |
} |
} |
131 |
145 |
} |
} |
132 |
146 |
|
|
File src/commands.c changed (mode: 100644) (index f13e204ff..7515c9fae) |
... |
... |
get_cmd_name_info(const char *cmd_line, size_t *len) |
161 |
161 |
cmd_line++; |
cmd_line++; |
162 |
162 |
} |
} |
163 |
163 |
|
|
164 |
|
if(cmd_line[0] == '!') |
|
165 |
|
return COM_EXECUTE; |
|
|
164 |
|
if(cmd_line[0] == '!') { |
|
165 |
|
if(len != NULL) |
|
166 |
|
*len = 1; |
|
167 |
|
return cmd_line; |
|
168 |
|
} |
166 |
169 |
|
|
167 |
170 |
if((p = strchr(cmd_line, ' ')) == NULL) |
if((p = strchr(cmd_line, ' ')) == NULL) |
168 |
171 |
p = cmd_line + strlen(cmd_line); |
p = cmd_line + strlen(cmd_line); |
|
... |
... |
comm_cd(FileView *view, cmd_t *cmd) |
1233 |
1236 |
moveto_list_pos(view, view->list_pos); |
moveto_list_pos(view, view->list_pos); |
1234 |
1237 |
} |
} |
1235 |
1238 |
|
|
|
1239 |
|
char * |
|
1240 |
|
fast_run_complete(char *cmd) |
|
1241 |
|
{ |
|
1242 |
|
char *buf = NULL; |
|
1243 |
|
char *completed1, *completed2; |
|
1244 |
|
char *p; |
|
1245 |
|
|
|
1246 |
|
p = strchr(cmd, ' '); |
|
1247 |
|
if(p == NULL) |
|
1248 |
|
p = cmd + strlen(cmd); |
|
1249 |
|
else |
|
1250 |
|
*p = '\0'; |
|
1251 |
|
|
|
1252 |
|
completed1 = exec_completion(cmd); |
|
1253 |
|
completed2 = exec_completion(NULL); |
|
1254 |
|
|
|
1255 |
|
if(strcmp(cmd, completed2) != 0) |
|
1256 |
|
{ |
|
1257 |
|
status_bar_message("Command beginning is ambiguous"); |
|
1258 |
|
} |
|
1259 |
|
else |
|
1260 |
|
{ |
|
1261 |
|
buf = malloc(strlen(completed1) + 1 + strlen(p) + 1); |
|
1262 |
|
sprintf(buf, "%s %s", completed1, p); |
|
1263 |
|
} |
|
1264 |
|
free(completed2); |
|
1265 |
|
free(completed1); |
|
1266 |
|
|
|
1267 |
|
return buf; |
|
1268 |
|
} |
|
1269 |
|
|
1236 |
1270 |
int |
int |
1237 |
1271 |
execute_builtin_command(FileView *view, cmd_t *cmd) |
execute_builtin_command(FileView *view, cmd_t *cmd) |
1238 |
1272 |
{ |
{ |
|
... |
... |
execute_builtin_command(FileView *view, cmd_t *cmd) |
1262 |
1296 |
} |
} |
1263 |
1297 |
while(isspace(com[i]) && i < strlen(com)) |
while(isspace(com[i]) && i < strlen(com)) |
1264 |
1298 |
i++; |
i++; |
1265 |
|
if(strlen(com + i) > 0 && cmd->background) |
|
|
1299 |
|
|
|
1300 |
|
if(strlen(com + i) == 0) |
|
1301 |
|
{ |
|
1302 |
|
free(com); |
|
1303 |
|
break; |
|
1304 |
|
} |
|
1305 |
|
|
|
1306 |
|
if(cmd->background) |
1266 |
1307 |
start_background_job(com + i); |
start_background_job(com + i); |
1267 |
|
else if(strlen(com + i) > 0) |
|
|
1308 |
|
else |
1268 |
1309 |
{ |
{ |
1269 |
1310 |
if(shellout(com + i, pause) == 127 && curr_stats.fast_run) |
if(shellout(com + i, pause) == 127 && curr_stats.fast_run) |
1270 |
1311 |
{ |
{ |
1271 |
|
char *completed1, *completed2; |
|
1272 |
|
char *p = strchr(com + i, ' '); |
|
1273 |
|
if(p == NULL) |
|
1274 |
|
p = com + i + strlen(com + i); |
|
1275 |
|
else |
|
1276 |
|
*p = '\0'; |
|
1277 |
|
completed1 = exec_completion(com + i); |
|
1278 |
|
completed2 = exec_completion(NULL); |
|
1279 |
|
if(strcmp(com + i, completed2) != 0) |
|
1280 |
|
{ |
|
1281 |
|
status_bar_message("Command beginning is ambiguous"); |
|
|
1312 |
|
char *buf = fast_run_complete(com + i); |
|
1313 |
|
if(buf == NULL) |
1282 |
1314 |
save_msg = 1; |
save_msg = 1; |
1283 |
|
} |
|
1284 |
1315 |
else |
else |
1285 |
|
{ |
|
1286 |
|
char *buf; |
|
1287 |
|
buf = malloc(strlen(completed1) + 1 + strlen(p) + 1); |
|
1288 |
|
sprintf(buf, "%s %s", completed1, p); |
|
1289 |
1316 |
shellout(buf, pause); |
shellout(buf, pause); |
1290 |
|
free(buf); |
|
1291 |
|
} |
|
1292 |
|
free(completed2); |
|
1293 |
|
free(completed1); |
|
|
1317 |
|
free(buf); |
1294 |
1318 |
} |
} |
1295 |
1319 |
} |
} |
1296 |
1320 |
|
|
File src/commands.h changed (mode: 100644) (index 4fdaff250..6c284de8b) |
... |
... |
int exec_commands(char *cmd, FileView *view, int type, void * ptr, |
98 |
98 |
int shellout(char *command, int pause); |
int shellout(char *command, int pause); |
99 |
99 |
void add_command(char *name, char *action); |
void add_command(char *name, char *action); |
100 |
100 |
int execute_command(FileView *view, char *action); |
int execute_command(FileView *view, char *action); |
|
101 |
|
char * fast_run_complete(char *cmd); |
101 |
102 |
int sort_this(const void *one, const void *two); |
int sort_this(const void *one, const void *two); |
102 |
103 |
int is_user_command(char *command); |
int is_user_command(char *command); |
103 |
104 |
int command_is_reserved(char *command); |
int command_is_reserved(char *command); |