Skip to content

Commit a1aced6

Browse files
authored
Update lseek.c
1 parent db93038 commit a1aced6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lseek_builtin/lseek.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ static char *lseek_doc[] = {
3737
"negative <REL_OFFSET> rewinds the <FD>",
3838
"",
3939
"SEEK_TYPE is optional and can take the value of:",
40-
" 'SEEK_SET' 'SEEK_CUR' 'SEEK_END'",
41-
" If omitted or invalid, SEEK_CUR is used.",
40+
" 'SEEK_SET' 'SEEK_CUR' 'SEEK_END'",
41+
" If omitted, SEEK_CUR is used.",
4242
"----------------------------------------------",
4343
"",
4444
NULL
@@ -56,7 +56,6 @@ struct builtin lseek_struct = {
5656

5757
// main function
5858
static int lseek_main(int argc, char **argv) {
59-
int whence = SEEK_CUR
6059

6160
// check for exactly 2 or 3 args passed to lseek
6261
if (argc != 3 && argc != 4) {
@@ -86,9 +85,7 @@ static int lseek_main(int argc, char **argv) {
8685
whence = SEEK_SET;
8786
} else if (strcmp(argv[3], "SEEK_END") == 0) {
8887
whence = SEEK_END;
89-
} else if (strcmp(argv[3], "SEEK_CUR") == 0) {
90-
whence = SEEK_CUR;
91-
} else {
88+
} else if (strcmp(argv[3], "SEEK_CUR") != 0) {
9289
fprintf(stderr, "Error: Invalid SEEK_TYPE. Must be SEEK_SET, SEEK_CUR, or SEEK_END\n");
9390
return 1;
9491
}

0 commit comments

Comments
 (0)