1
0
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:
Dado Sutter 2009-11-23 20:05:28 +00:00
parent a70beaf857
commit 77b6c6ca68

View File

@ -193,30 +193,30 @@ 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( ( fp = fopen( args , "rb" ) ) != NULL ) {
c = fgetc( fp );
while( c != EOF ) {
printf("%c", (char) c );
if ( *args )
if( ( fp = fopen( args , "rb" ) ) != NULL ) {
c = fgetc( fp );
while( c != EOF ) {
printf("%c", (char) c );
c = fgetc( fp );
}
fclose ( fp );
}
fclose ( fp );
}
else
if ( *args )
printf( "File %s not found\n", args );
else
printf( "Usage: cat (or type) <filename>\n" );
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[] =
{