diff options
Diffstat (limited to 'bin/hilex.c')
-rw-r--r-- | bin/hilex.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/bin/hilex.c b/bin/hilex.c index 8a03eb80..7d7b3f2d 100644 --- a/bin/hilex.c +++ b/bin/hilex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 C. McEnroe <june@causal.agency> +/* Copyright (C) 2020 June McEnroe <june@causal.agency> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -53,7 +53,7 @@ static const struct { { &LexC, "c", "[.][chlmy]$", NULL }, { &LexMake, "make", "[.](mk|am)$|^Makefile$", NULL }, { &LexMdoc, "mdoc", "[.][1-9]$", "^[.]Dd" }, - { &LexSh, "sh", "[.]sh$|^[.](profile|shrc)$", "^#!/bin/sh" }, + { &LexSh, "sh", "[.]sh$|^[.](profile|shrc)$", "^#![ ]?/bin/k?sh" }, { &LexText, "text", "[.]txt$", NULL }, }; @@ -149,6 +149,11 @@ static void ansiHeader(const char *opts[]) { close(rw[0]); close(rw[1]); setlinebuf(stdout); + +#ifdef __OpenBSD__ + error = pledge("stdio", NULL); + if (error) err(EX_OSERR, "pledge"); +#endif } static void ansiFooter(const char *opts[]) { @@ -369,6 +374,16 @@ int main(int argc, char *argv[]) { pager = isatty(STDOUT_FILENO); } +#ifdef __OpenBSD__ + int error; + if (formatter->header == ansiHeader && pager) { + error = pledge("stdio proc exec", NULL); + } else { + error = pledge("stdio", NULL); + } + if (error) err(EX_OSERR, "pledge"); +#endif + if (!name) { if (NULL != (name = strrchr(path, '/'))) { name++; |