jira-cli
jira-cli copied to clipboard
without `tty`, `jira issue list` produces no output and hangs
Describe the bug
Without a pseudoterminal, jira issue list
hangs and produces (almost) no output.
Please provide following details
- JiraCLI Version:
0.1.1
, installed viago install github.com/ankitpokhrel/jira-cli/cmd/[email protected]
(Version="", GitCommit="", GoVersion="go1.17.1", BuildDate="", Compiler="gc", Platform="linux/amd64")
- Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation. No.
- What operating system are you using? Also mention version.
$ lsb_release --all Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS Release: 18.04 Codename: bionic
- What terminal are you using? Also mention version.
$ gnome-terminal --version # GNOME Terminal 3.28.2 using VTE 0.52.2 +GNUTLS -PCRE2
To Reproduce
$ nohup jira issue list 2>&1 &
[1] 20842
nohup: ignoring input and appending output to 'nohup.out'
$ jobs -l
[1]+ 20842 Stopped (tty output) nohup jira issue list 2>&1
$ kill -SIGKILL 20842
[1]+ Killed nohup jira issue list 2>&1
$ awk 1 nohup.out
â ¸ Fetching issues...
Expected behavior
jira-cli
should detect that standard output is not a terminal and fall back to printing --plain
output.
Screenshots See "To Reproduce" above.
Additional context None.
@realtime-neil not that I am against it but for me to understand better: is not having this fallback blocking you from doing something?
@ankitpokhrel this is not blocking anything. There is a work-around; i.e., pass --plain
when executing jira
without a tty
.
This functionality to detect a terminal on stdin/stdout is however, present in a lot of command line tools. For your consideration:
- GNU tar:
tar: Refusing to write archive contents to terminal (missing -f option?)
- docker:
the input device is not a TTY
- GNU screen:
Must be connected to a terminal.
- gzip:
-
gzip: compressed data not written to a terminal. Use -f to force compression.
-
gzip: compressed data not read from a terminal. Use -f to force decompression.
-
- bzip2:
-
bzip2: I won't write compressed data to a terminal.
-
bzip2: I won't read compressed data from a terminal.
-
- xz:
-
xz: Compressed data cannot be written to a terminal
-
xz: Compressed data cannot be read from a terminal
-
It's not hard to check if standard output is a tty: https://rosettacode.org/wiki/Check_output_device_is_a_terminal#Go
@ankitpokhrel How do you feel about the following proposals:
-
--plain
should always forcejira
to write "plain text" tostdout
-
--plain
should always forcejira
to ignore anytty
- if
--plain
is not given, thenjira
should acquire atty
if and only if atty
exists; elsejira
writes "plain text" tostdout
Hi @realtime-neil, could you please help to check if #538 fixes this issue? TIA
@ankitpokhrel I've checked and, no, it did not:
$ jira version
(Version="v1.2.1-0.20221222104938-69b789b1d5b1", GitCommit="", CommitDate="", GoVersion="go1.19.3", Compiler="gc", Platform="linux/amd64")
$ nohup jira issue list 2>&1 &
[1] 2169727
nohup: ignoring input and appending output to 'nohup.out'
$ jobs -l
[1]+ 2169727 Stopped (tty output) nohup jira issue list 2>&1
$ kill -SIGKILL 2169727
[1]+ Killed nohup jira issue list 2>&1
$ wc nohup.out
0 0 0 nohup.out
The only difference is that jira
has produced no output.
Whoops, my bad! I had to
$ go install github.com/ankitpokhrel/jira-cli/cmd/jira@issue-187
...which totally did fix the issue.
Thank you for reporting and helping with the tests @realtime-neil 🙇