mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
cat/type command cosmetic refactoring
This commit is contained in:
parent
a70beaf857
commit
77b6c6ca68
@ -193,14 +193,13 @@ static void shell_ls( char* args )
|
|||||||
// 'cat' and 'type' handler
|
// 'cat' and 'type' handler
|
||||||
static void shell_cat( char *args )
|
static void shell_cat( char *args )
|
||||||
{
|
{
|
||||||
args = args;
|
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
// replace *args ending space with a string terminator
|
// *args has an appended space. Replace it with the string terminator.
|
||||||
*(strchr( args, ' ' )) = 0;
|
*(strchr( args, ' ' )) = 0;
|
||||||
|
|
||||||
|
if ( *args )
|
||||||
if( ( fp = fopen( args , "rb" ) ) != NULL ) {
|
if( ( fp = fopen( args , "rb" ) ) != NULL ) {
|
||||||
c = fgetc( fp );
|
c = fgetc( fp );
|
||||||
while( c != EOF ) {
|
while( c != EOF ) {
|
||||||
@ -210,13 +209,14 @@ static void shell_cat( char *args )
|
|||||||
fclose ( fp );
|
fclose ( fp );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ( *args )
|
|
||||||
printf( "File %s not found\n", args );
|
printf( "File %s not found\n", args );
|
||||||
else
|
else
|
||||||
printf( "Usage: cat (or type) <filename>\n" );
|
printf( "Usage: cat (or type) <filename>\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Insert shell commands here
|
// Insert shell commands here
|
||||||
static const SHELL_COMMAND shell_commands[] =
|
static const SHELL_COMMAND shell_commands[] =
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user