k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 9486a5004ef24a008d2aa2f12c9d5eaecad0c431
parent f458b93c2b54973eb0e9b238b0d1d0b8242ffeb9
Author: call-cc <callcc@vxempire.xyz>
Date:   Tue,  2 Jun 2020 16:53:42 -0400

Add -f flag to ln

Diffstat:
Msrc/ln.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/ln.c b/src/ln.c @@ -10,13 +10,16 @@ main(int argc, char *argv[]) printf("Usage: ln oldfile newfile\n"); return 1; } - int opts; - int fd; - while((opts = getopt(argc, argv, "s:")) != -1) + int opts, fd, fflag; + while((opts = getopt(argc, argv, "sf")) != -1) { switch(opts) { - case 's': + case 'f': + fflag=1; + case 's': + if(fflag && (access(argv[3], F_OK) != 1)) + unlink(argv[3]); symlink(argv[2],argv[3]); break; case '?':