~serge-hallyn/ubuntu/oneiric/ipxe/link-kvm

« back to all changes in this revision

Viewing changes to src/hci/shell.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2011-07-31 20:57:02 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110731205702-kffmzz6tnmgfw50f
Tags: 1.0.0+git-2.149b50-1
New snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <stdint.h>
22
22
#include <stdlib.h>
23
23
#include <stdio.h>
 
24
#include <string.h>
24
25
#include <getopt.h>
25
26
#include <readline/readline.h>
26
27
#include <ipxe/command.h>
75
76
 *
76
77
 */
77
78
int shell ( void ) {
 
79
        struct readline_history history;
78
80
        char *line;
79
81
        int rc = 0;
80
82
 
 
83
        /* Initialise shell history */
 
84
        memset ( &history, 0, sizeof ( history ) );
 
85
 
 
86
        /* Read and execute commands */
81
87
        do {
82
 
                line = readline ( shell_prompt );
 
88
                line = readline_history ( shell_prompt, &history );
83
89
                if ( line ) {
84
90
                        rc = system ( line );
85
91
                        free ( line );
86
92
                }
87
93
        } while ( ! shell_stopped ( SHELL_STOP_COMMAND_SEQUENCE ) );
88
94
 
 
95
        /* Discard shell history */
 
96
        history_free ( &history );
 
97
 
89
98
        return rc;
90
99
}
91
100