not sure
This commit is contained in:
parent
f315bdf4ae
commit
c21ca4a2ce
7
cat/Makefile
Normal file
7
cat/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
cat: cat.c
|
||||
$(CC) -g -o cat cat.c
|
||||
|
||||
clean:
|
||||
rm -f cat.c
|
||||
|
||||
.PHONY: clean
|
@ -14,7 +14,7 @@ static char *default_argv[] = {
|
||||
"-",
|
||||
(char *)NULL
|
||||
};
|
||||
static char *stdout_name = "/dev/stdout";
|
||||
static char *stdout_name = "/dev/stdin";
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int arguing;
|
||||
@ -54,8 +54,8 @@ int main(int argc, char *argv[]){
|
||||
continue;
|
||||
}
|
||||
if(*argv[optind] == '-' && argv[optind][1] == '\0'){ /* "-" */
|
||||
fn = stdout_name;
|
||||
fo = stdout;
|
||||
fn = stdin_name;
|
||||
fo = stdin;
|
||||
}else{
|
||||
fn = argv[optind];
|
||||
if(stat(fn, &fi) == -1){
|
||||
@ -103,6 +103,7 @@ int main(int argc, char *argv[]){
|
||||
return EX_UNAVAILABLE;
|
||||
}
|
||||
|
||||
if(fo != stdin)
|
||||
fclose(fo);
|
||||
++optind;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user