|
@@ -304,7 +304,7 @@ static int imgexec_exec ( int argc, char **argv ) {
|
304
|
304
|
{ NULL, 0, NULL, 0 },
|
305
|
305
|
};
|
306
|
306
|
struct image *image;
|
307
|
|
- const char *name;
|
|
307
|
+ const char *name = NULL;
|
308
|
308
|
int c;
|
309
|
309
|
int rc;
|
310
|
310
|
|
|
@@ -320,19 +320,29 @@ static int imgexec_exec ( int argc, char **argv ) {
|
320
|
320
|
}
|
321
|
321
|
}
|
322
|
322
|
|
323
|
|
- /* Need exactly one image name */
|
324
|
|
- if ( optind != ( argc - 1 ) ) {
|
|
323
|
+ /* Need no more than one image name */
|
|
324
|
+ if ( optind != argc )
|
|
325
|
+ name = argv[optind++];
|
|
326
|
+ if ( optind != argc ) {
|
325
|
327
|
imgexec_syntax ( argv );
|
326
|
328
|
return 1;
|
327
|
329
|
}
|
328
|
|
- name = argv[optind];
|
329
|
330
|
|
330
|
331
|
/* Execute specified image */
|
331
|
|
- image = find_image ( name );
|
332
|
|
- if ( ! image ) {
|
333
|
|
- printf ( "No such image: %s\n", name );
|
334
|
|
- return 1;
|
|
332
|
+ if ( name ) {
|
|
333
|
+ image = find_image ( name );
|
|
334
|
+ if ( ! image ) {
|
|
335
|
+ printf ( "No such image: %s\n", name );
|
|
336
|
+ return 1;
|
|
337
|
+ }
|
|
338
|
+ } else {
|
|
339
|
+ image = imgautoselect();
|
|
340
|
+ if ( ! image ) {
|
|
341
|
+ printf ( "No loaded images\n" );
|
|
342
|
+ return 1;
|
|
343
|
+ }
|
335
|
344
|
}
|
|
345
|
+
|
336
|
346
|
if ( ( rc = imgexec ( image ) ) != 0 ) {
|
337
|
347
|
printf ( "Could not execute %s: %s\n", name, strerror ( rc ) );
|
338
|
348
|
return 1;
|
|
@@ -448,7 +458,6 @@ static int imgfree_exec ( int argc, char **argv ) {
|
448
|
458
|
return 0;
|
449
|
459
|
}
|
450
|
460
|
|
451
|
|
-
|
452
|
461
|
/** Image management commands */
|
453
|
462
|
struct command image_commands[] __command = {
|
454
|
463
|
{
|