From 8f38a8169055de2a1fef8d4bfeb6d8ae36b78e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Fri, 12 Aug 2022 13:37:31 -0300 Subject: [PATCH] Add some command line options. - delimiter choice - compatibility with fzf --- ef.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ef.c b/ef.c index 3c6e309..8a172df 100644 --- a/ef.c +++ b/ef.c @@ -35,11 +35,26 @@ static void signal_handler(int signum) write(signal_pipe[1], &signum, sizeof signum); } -int main() +int main(int argc, char **argv) { setlocale(LC_ALL, ""); - const char delim = '\n'; + char delim = '\n'; + + int opt; + while ((opt = getopt(argc, argv, "01")) != -1) { + switch (opt) { + case '0': + /* set delimiter to NUL char instead of newline */ + delim = '\0'; + break; + case '1': + /* ignored for compatibility with fzf */ + break; + default: + exit(1); + } + } if (pipe(signal_pipe)) { perror("pipe");