snazzer icon indicating copy to clipboard operation
snazzer copied to clipboard

Added a --progress option for snazzer-receive.

Open DL6AKU opened this issue 8 years ago • 9 comments

Fixes #39

DL6AKU avatar Oct 27 '16 17:10 DL6AKU

Good idea!

I'm thinking about whether the explicit command line option is really needed though - maybe we could turn progress metering automatically if snazzer is run interactively, i.e. stderr is a tty with a user in front of it? In fish there's isatty but I don't know how to do that reliably in bash. :wink:

florianjacob avatar Oct 27 '16 18:10 florianjacob

Seems like checking that when run in a terminal via ssh is not that trivial in bash, though…

florianjacob avatar Oct 27 '16 18:10 florianjacob

We could show the progress by default if pv is installed. That would actually make for a simpler patch. I did not want to go so far though with my patch. Such a default behaviour would have to be decided by the project maintainer I guess (@csirac2).

DL6AKU avatar Oct 27 '16 19:10 DL6AKU

Great idea! I would love to see receive progress indicator by default, ssh does look fiddly to detect though.

My only concern with the code is that I would like to avoid eval.

csirac2 avatar Oct 27 '16 20:10 csirac2

Afaik it wouldn't hurt ssh if it was enabled for ssh as well (so we skip the ssh detection), though I did not look into the ssh option just now.

I do not know about bash magic enough to avoid the eval. I tried without, but then you get a double pipe or pv: | not found errors. Or you get more nested ifs.

I can look into expansion of the patch tomorrow.

DL6AKU avatar Oct 27 '16 21:10 DL6AKU

To be more explicit: If possible, the progress meter should show automatically in three cases:

  • virtual terminals used interactively
  • terminal emulators used interactively
  • ssh sessions used interactively

It shouldn't show if snazzer is started from inside a shell script, a cron job or a systemd timer, or when the stderr is redirected to a file or something else that is not a tty.

References: http://stackoverflow.com/questions/911168/how-to-detect-if-my-shell-script-is-running-through-a-pipe Maybe helpful: http://tldp.org/LDP/abs/html/intandnonint.html

florianjacob avatar Oct 28 '16 15:10 florianjacob

Regarding the conditional pipeline issue, this looks like a solution that does not need eval or another if level: http://unix.stackexchange.com/questions/38310/conditional-pipeline

florianjacob avatar Oct 28 '16 15:10 florianjacob

I'm not sure I'll get it to it this weekend, and I'm in a crunch at work for the next week, but I'll try to take a look next weekend.

csirac2 avatar Oct 28 '16 23:10 csirac2

Just FYI, I am no no longer using snazzer, so I won't be actively working towards a patch.

DL6AKU avatar Dec 12 '16 20:12 DL6AKU