Untitled
unknown
plain_text
2 years ago
940 B
3
Indexable
#include "simple_shell.h" #include <stdbool.h> #include <stdio.h> #include <unistd.h> void set_command_entry_data(command_entry_t *entry) { entry->pid = getpid(); entry->is_interactive = display_prompt(); entry->command = read_command(entry); } bool display_prompt(void) { const char *prompt_text = "$ "; int nbytes = _strlen(prompt_text), nbytes_written; /* Check if standard input is a terminal */ if (isatty(STDIN_FILENO)) { nbytes_written = write(STDOUT_FILENO, prompt_text, nbytes); if (nbytes_written == -1) { perror("Error writing prompt"); return (false); } fflush(stdout); return (true); } return (false); } char *read_command(command_entry_t *entry) { ; }
Editor is loading...