I hate git.
This commit is contained in:
commit
66dbedad82
1
TODO
1
TODO
|
@ -1,3 +1,4 @@
|
||||||
* The rest of programs.
|
* The rest of programs.
|
||||||
* Manuals
|
* Manuals
|
||||||
* flags for the programs
|
* flags for the programs
|
||||||
|
* fix yes (constantly returns y when no argument is passed)
|
25
src/ln.c
25
src/ln.c
|
@ -1,8 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* TODO -s flag */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -12,16 +10,21 @@ main(int argc, char *argv[])
|
||||||
printf("Usage: ln oldfile newfile\n");
|
printf("Usage: ln oldfile newfile\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
int opts;
|
||||||
int c = getopt(argc, argv, "s");
|
int fd;
|
||||||
if(c == 's')
|
/* I am aware that this doesn't conform to style, but it's the only option that actually works */
|
||||||
|
while((opts = getopt(argc, argv, "s:")) != -1)
|
||||||
{
|
{
|
||||||
|
switch(opts)
|
||||||
|
{
|
||||||
|
case 's':
|
||||||
symlink(argv[2],argv[3]);
|
symlink(argv[2],argv[3]);
|
||||||
return 0;
|
break;
|
||||||
}
|
case '?':
|
||||||
|
printf("-%c: Argument not found", optopt);
|
||||||
|
break;
|
||||||
int fd = link(argv[1],argv[2]);
|
default:
|
||||||
|
fd = link(argv[1],argv[2]);
|
||||||
if(fd == -1)
|
if(fd == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Error creating link\n");
|
fprintf(stderr,"Error creating link\n");
|
||||||
|
@ -29,3 +32,5 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue