From 4454c4796165ecf353e46f571f4923c220c8ab58 Mon Sep 17 00:00:00 2001 From: Nelo Mitranim Date: Mon, 10 Apr 2023 11:02:00 +0200 Subject: [PATCH] minor cosmetics and readme additions --- go.sum | 4 ++-- gow_cmd.go | 2 ++ gow_flag.go | 2 +- gow_misc.go | 5 ++++- readme.md | 13 +++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/go.sum b/go.sum index e01011f..b143c5e 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/mitranim/gg v0.0.13 h1:gMmGRzkF8ARhxUSXAHEE1CB64ipaXpEFjgzmxclGBZ0= github.com/mitranim/gg v0.0.13/go.mod h1:UCnf53suG0iX7c9P8tnH6L7iTT9LpMyhQQMVjwi5Jt0= -github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8= -github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= +github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY= +github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc= golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 h1:J27LZFQBFoihqXoegpscI10HpjZ7B5WQLLKL2FZXQKw= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/gow_cmd.go b/gow_cmd.go index 9215606..fc33bd3 100644 --- a/gow_cmd.go +++ b/gow_cmd.go @@ -83,6 +83,8 @@ func (self *Cmd) BroadcastUnsync(sig syscall.Signal) { } func (self *Cmd) WriteChar(char byte) { + // Locking and unlocking for every character might be wasteful. + // Might even be stupidly wasteful. TODO measure. defer gg.Lock(self).Unlock() stdin := self.Stdin diff --git a/gow_flag.go b/gow_flag.go index 07e4aae..4e2b9fd 100644 --- a/gow_flag.go +++ b/gow_flag.go @@ -10,7 +10,7 @@ import ( type FlagStrMultiline string func (self *FlagStrMultiline) Parse(src string) error { - *self += FlagStrMultiline(withNewline(REP_SINGLE_MULTI(src))) + *self += FlagStrMultiline(withNewline(REP_SINGLE_MULTI.Replace(src))) return nil } diff --git a/gow_misc.go b/gow_misc.go index 296236b..3baf0a3 100644 --- a/gow_misc.go +++ b/gow_misc.go @@ -11,12 +11,15 @@ import ( ) const ( + // These names reflect standard naming and meaning. + // See our re-interpretation below. ASCII_END_OF_TEXT = 3 // ^C ASCII_FILE_SEPARATOR = 28 // ^\ ASCII_DEVICE_CONTROL_2 = 18 // ^R ASCII_DEVICE_CONTROL_4 = 20 // ^T ASCII_UNIT_SEPARATOR = 31 // ^- or ^? + // These names reflect our re-interpretation of standard codes. CODE_INTERRUPT = ASCII_END_OF_TEXT CODE_QUIT = ASCII_FILE_SEPARATOR CODE_RESTART = ASCII_DEVICE_CONTROL_2 @@ -35,7 +38,7 @@ var ( `\r\n`, gg.Newline, `\r`, gg.Newline, `\n`, gg.Newline, - ).Replace + ) ) /** diff --git a/readme.md b/readme.md index 92fe658..b611391 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,7 @@ Currently requires Unix (MacOS, Linux, BSD). On Windows, runs under WSL. * [Installation](#installation) * [Usage](#usage) * [Hotkeys](#hotkeys) +* [Gotchas](#gotchas) * [Watching Templates](#watching-templates) * [Alternatives](#alternatives) * [License](#license) @@ -94,6 +95,18 @@ Supported control codes with commonly associated hotkeys. Exact keys may vary be Other input is forwarded to the subprocess as-is. +## Gotchas + +By default, `gow` expects to be used in a foreground, interactive terminal. When running `gow` in a background process, Docker, or any other non-interactive environment, you may see errors similar to the below. To avoid the problem, run `gow` with `-r=false`. This also disables hotkey support. + +``` +unable to read terminal state + +inappropriate ioctl for device + +operation not supported by device +``` + ## Watching Templates Many Go programs, such as servers, include template files, and want to recompile those templates on change.