commit 30163bbe5103ee3b87f11ebcbe44ac8e8f3ccfc1
parent 6cf9c0e99e3f9f2eb3987ec2732f630b55ec680f
Author: Louis Burda <quent.burda@gmail.com>
Date: Sat, 17 Jun 2023 20:17:39 +0200
fixup! Add usage and fix sigint handler
Diffstat:
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tquery.c b/tquery.c
@@ -38,9 +38,9 @@ static struct nav output_nav;
static char inputbuf[2048] = { 0 };
static size_t inputlen = 0;
-static bool separate = false;
-static bool oneshot = false;
-static bool openerr = false;
+static bool splitargs = false;
+static bool single = false;
+static bool childerr = false;
static char delim = '\n';
static const char **child_argv = NULL;
@@ -210,7 +210,7 @@ spawn(const char **prefix, const char *query)
if (child_pid < 0) die("fork:");
if (!child_pid) {
close(0);
- if (openerr) {
+ if (childerr) {
swapfd(1, 2);
close(1);
} else {
@@ -229,7 +229,7 @@ spawn(const char **prefix, const char *query)
argv[argc++] = *arg;
}
- if (separate) {
+ if (splitargs) {
ntok = tok = query;
while (ntok && *ntok && argc < 64) {
ntok = strchr(tok, ' ');
@@ -400,7 +400,7 @@ input(void)
case '\n':
if (output_nav.sel >= 0) {
fputs(entry((size_t) output_nav.sel), stderr);
- if (oneshot) exit(0);
+ if (single) exit(0);
}
break;
default:
@@ -446,12 +446,12 @@ parse(int argc, const char **argv)
for (arg = &argv[1]; *arg; arg++) {
if (!strcmp(*arg, "-h") || !strcmp(*arg, "--help")) {
usage(0, true);
- } else if (!strcmp(*arg, "-o") || !strcmp(*arg, "--oneshot")) {
- oneshot = true;
- } else if (!strcmp(*arg, "-e") || !strcmp(*arg, "--openerr")) {
- openerr = true;
- } else if (!strcmp(*arg, "-s") || !strcmp(*arg, "--separate")) {
- separate = true;
+ } else if (!strcmp(*arg, "-s") || !strcmp(*arg, "--single")) {
+ single = true;
+ } else if (!strcmp(*arg, "-e") || !strcmp(*arg, "--stderr")) {
+ childerr = true;
+ } else if (!strcmp(*arg, "-a") || !strcmp(*arg, "--args")) {
+ splitargs = true;
} else if (!strcmp(*arg, "-d") || !strcmp(*arg, "--delim")) {
delim = **++arg;
} else if (!strcmp(*arg, "--")) {