hautils

[hare] Set of POSIX utilities
Log | Files | Refs | README | LICENSE

commit e6e0c2c14e2bbb1b7de015e009cdfd793e68dab7
parent 7387e0135e7c00626f33d6ddc8b9c2995e8d06e6
Author: Byron Torres <b@torresjrjr.com>
Date:   Mon, 12 Jun 2023 01:52:42 +0000

uniq: fix config initialization

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Muniq.ha | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/uniq.ha b/uniq.ha @@ -106,7 +106,11 @@ export fn utilmain() (main::error | void) = { const cmd = getopt::parse(os::args, help...); defer getopt::finish(&cmd); - let cfg = config{...}; + let cfg = config { + input = os::stdin, + output = os::stdout, + ... + }; for (let i = 0z; i < len(cmd.opts); i += 1) { const opt = cmd.opts[i]; @@ -133,7 +137,6 @@ export fn utilmain() (main::error | void) = { static const stdin_rbuf: [os::BUFSIZ]u8 = [0...]; static const stdin_wbuf: [os::BUFSIZ]u8 = [0...]; - cfg.input = os::stdin; if (len(cmd.args) >= 1 && cmd.args[0] != "-") { match (os::open(cmd.args[0])) { case let err: fs::error => @@ -146,7 +149,6 @@ export fn utilmain() (main::error | void) = { }; defer io::close(cfg.input)!; - cfg.output = os::stdout; static const stdout_rbuf: [os::BUFSIZ]u8 = [0...]; static const stdout_wbuf: [os::BUFSIZ]u8 = [0...]; if (len(cmd.args) == 2) {