create the shell loop
This commit is contained in:
parent
16bdb27904
commit
cc74038008
13
Makefile
13
Makefile
@ -1,13 +1,14 @@
|
|||||||
CC=clang
|
CC=clang
|
||||||
CFLAGS=-Wall -Isrc/include -DDEBUG -g
|
CFLAGS=-Wall -Isrc/include -DDEBUG -g -std=c17
|
||||||
LDFLAGS=-lm
|
LDFLAGS=
|
||||||
SRC=src/myshellin.c
|
FILENAME=myshellin
|
||||||
|
SRC=src/myshellin.c src/loop.c
|
||||||
OBJ=$(SRC:.c=.o)
|
OBJ=$(SRC:.c=.o)
|
||||||
|
|
||||||
all: myshellin informe
|
all: myshellin
|
||||||
|
|
||||||
myshellin: $(OBJ)
|
myshellin: $(OBJ)
|
||||||
$(CC) -o $@ $^ $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $(FILENAME) $^ $(LDFLAGS)
|
||||||
|
|
||||||
informe:
|
informe:
|
||||||
# if pdflatex is installed create the informe
|
# if pdflatex is installed create the informe
|
||||||
@ -16,7 +17,7 @@ ifneq (, $(shell which pdflatex))
|
|||||||
mv doc/Informe.pdf Informe.pdf
|
mv doc/Informe.pdf Informe.pdf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean: cleanmyshellin cleaninforme
|
clean: cleanmyshellin
|
||||||
|
|
||||||
cleanmyshellin:
|
cleanmyshellin:
|
||||||
rm -f src/*.o myshellin
|
rm -f src/*.o myshellin
|
||||||
|
2
src/include/loop.h
Normal file
2
src/include/loop.h
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
void print_input_line();
|
||||||
|
void loop();
|
18
src/loop.c
Normal file
18
src/loop.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
void print_input_line() {
|
||||||
|
printf("$ ");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
size_t buffer_size = 0;
|
||||||
|
char *line = NULL;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
print_input_line();
|
||||||
|
getline(&line, &buffer_size, stdin);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
int main(int argc, char **argv)
|
#include "loop.h"
|
||||||
{
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
loop();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user