From 58a54e3b6b26827b979a1fe8d5bfe27eefdb46a9 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Mon, 16 Sep 2019 17:09:49 -0400 Subject: Set default nick to USER unless -P --- chat.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'chat.c') diff --git a/chat.c b/chat.c index 021ac77..7e1a9aa 100644 --- a/chat.c +++ b/chat.c @@ -53,9 +53,10 @@ int main(int argc, char *argv[]) { setlocale(LC_CTYPE, ""); int opt; - while (0 < (opt = getopt(argc, argv, "NRW:a:h:j:k:l:n:p:r:u:vw:"))) { + while (0 < (opt = getopt(argc, argv, "NPRW:a:h:j:k:l:n:p:r:u:vw:"))) { switch (opt) { break; case 'N': self.notify = true; + break; case 'P': self.nick = prompt("Name: "); break; case 'R': self.limit = true; break; case 'W': self.webp = dupe(optarg); break; case 'a': self.auth = dupe(optarg); @@ -73,9 +74,14 @@ int main(int argc, char *argv[]) { } } + if (!self.nick) { + const char *user = getenv("USER"); + if (!user) errx(EX_USAGE, "USER unset"); + self.nick = dupe(user); + } + if (!self.host) self.host = prompt("Host: "); if (!self.port) self.port = dupe("6697"); - if (!self.nick) self.nick = prompt("Name: "); if (!self.user) self.user = dupe(self.nick); if (!self.real) self.real = dupe(self.nick); -- cgit 1.4.1-2-gfad0