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
|
(char *)NULL
|
||||||
};
|
};
|
||||||
static char *stdout_name = "/dev/stdout";
|
static char *stdout_name = "/dev/stdin";
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
int arguing;
|
int arguing;
|
||||||
@ -54,8 +54,8 @@ int main(int argc, char *argv[]){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(*argv[optind] == '-' && argv[optind][1] == '\0'){ /* "-" */
|
if(*argv[optind] == '-' && argv[optind][1] == '\0'){ /* "-" */
|
||||||
fn = stdout_name;
|
fn = stdin_name;
|
||||||
fo = stdout;
|
fo = stdin;
|
||||||
}else{
|
}else{
|
||||||
fn = argv[optind];
|
fn = argv[optind];
|
||||||
if(stat(fn, &fi) == -1){
|
if(stat(fn, &fi) == -1){
|
||||||
@ -103,7 +103,8 @@ int main(int argc, char *argv[]){
|
|||||||
return EX_UNAVAILABLE;
|
return EX_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fo);
|
if(fo != stdin)
|
||||||
|
fclose(fo);
|
||||||
++optind;
|
++optind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user