jira-cli icon indicating copy to clipboard operation
jira-cli copied to clipboard

without `tty`, `jira issue list` produces no output and hangs

Open realtime-neil opened this issue 2 years ago • 3 comments

Describe the bug Without a pseudoterminal, jira issue list hangs and produces (almost) no output.

Please provide following details

  1. JiraCLI Version: 0.1.1, installed via go install github.com/ankitpokhrel/jira-cli/cmd/[email protected]
    (Version="", GitCommit="", GoVersion="go1.17.1", BuildDate="", Compiler="gc", Platform="linux/amd64")
    
  2. Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation. No.
  3. 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
    
  4. 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 avatar Nov 08 '21 15:11 realtime-neil

@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 avatar Nov 08 '21 21:11 ankitpokhrel

@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

realtime-neil avatar Nov 09 '21 21:11 realtime-neil

@ankitpokhrel How do you feel about the following proposals:

  • --plain should always force jira to write "plain text" to stdout
  • --plain should always force jira to ignore any tty
  • if --plain is not given, then jira should acquire a tty if and only if a tty exists; else jira writes "plain text" to stdout

realtime-neil avatar Nov 23 '21 15:11 realtime-neil

Hi @realtime-neil, could you please help to check if #538 fixes this issue? TIA

ankitpokhrel avatar Dec 22 '22 18:12 ankitpokhrel

@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.

realtime-neil avatar Dec 22 '22 18:12 realtime-neil

Whoops, my bad! I had to

$ go install github.com/ankitpokhrel/jira-cli/cmd/jira@issue-187

...which totally did fix the issue.

realtime-neil avatar Dec 22 '22 18:12 realtime-neil

Thank you for reporting and helping with the tests @realtime-neil 🙇

ankitpokhrel avatar Dec 22 '22 20:12 ankitpokhrel