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
|
||||
static void shell_cat( char *args )
|
||||
{
|
||||
args = args;
|
||||
|
||||
FILE *fp;
|
||||
int c;
|
||||
|
||||
// replace *args ending space with a string terminator
|
||||
// *args has an appended space. Replace it with the string terminator.
|
||||
*(strchr( args, ' ' )) = 0;
|
||||
|
||||
if ( *args )
|
||||
if( ( fp = fopen( args , "rb" ) ) != NULL ) {
|
||||
c = fgetc( fp );
|
||||
while( c != EOF ) {
|
||||
@ -210,13 +209,14 @@ static void shell_cat( char *args )
|
||||
fclose ( fp );
|
||||
}
|
||||
else
|
||||
if ( *args )
|
||||
printf( "File %s not found\n", args );
|
||||
else
|
||||
printf( "Usage: cat (or type) <filename>\n" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Insert shell commands here
|
||||
static const SHELL_COMMAND shell_commands[] =
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user