Skip to content

Commit

Permalink
pwd: implemented pwd command
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Oct 3, 2024
1 parent ff35f28 commit 318e9bb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ all:
@make -C lush
@echo "\x1B[0;1;35m make\x1B[0m utilities/echo"
@make -C echo
@echo "\x1B[0;1;35m make\x1B[0m utilities/pwd"
@make -C pwd

install:
@mkdir -p out
Expand All @@ -18,6 +20,8 @@ install:
@make install -C lush
@echo "\x1B[0;1;35m make\x1B[0m install utilities/echo"
@make install -C echo
@echo "\x1B[0;1;35m make\x1B[0m install utilities/pwd"
@make install -C pwd

clean:
@echo "\x1B[0;1;35m make\x1B[0m clean utilities/hello"
Expand All @@ -28,3 +32,5 @@ clean:
@make clean -C lush
@echo "\x1B[0;1;35m make\x1B[0m clean utilities/echo"
@make clean -C echo
@echo "\x1B[0;1;35m make\x1B[0m clean utilities/pwd"
@make clean -C pwd
23 changes: 23 additions & 0 deletions pwd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PLATFORM=x86_64-lux
CCFLAGS=-Wall -c -O3
LDFLAGS=-llux
CC=x86_64-lux-gcc
LD=x86_64-lux-gcc
SRC:=$(shell find . -type f -name "*.c")
OBJ:=$(SRC:.c=.o)

all: pwd

%.o: %.c
@echo "\x1B[0;1;32m cc \x1B[0m $<"
@$(CC) $(CCFLAGS) -o $@ $<

pwd: $(OBJ)
@echo "\x1B[0;1;93m ld \x1B[0m pwd"
@$(LD) $(OBJ) -o pwd $(LDFLAGS)

install: pwd
@cp pwd ../out/

clean:
@rm -f pwd $(OBJ)
16 changes: 16 additions & 0 deletions pwd/pwd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* luxOS - a unix-like operating system
* Omar Elghoul, 2024
*
* echo: implementation of the pwd command
*/

#include <stdio.h>
#include <limits.h>
#include <unistd.h>

int main(void) {
char path[PATH_MAX];
sprintf("%s\n", getwd(path));
return 0;
}

0 comments on commit 318e9bb

Please sign in to comment.