From 9890961c159cf8786a7d1a197f65c80aebadf836 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sat, 14 Sep 2024 11:20:53 +0200 Subject: [PATCH] vid: Bug: stdin would never be detected as terminal. --- Makefile | 16 ++++++++-------- vid/vid | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index dbd17e9..fa13c9d 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ CMD = 2grep 2search audioping blink burncpu bwlimit clipboard drac \ gitdiffdir gitedit gitnext gitundo goodpasswd histogram \ Loffice mtrr mirrorpdf neno not off pdfman pidcmd pidtree \ plotpipe puniq ramusage rand rclean rina rn rrm seekmaniac \ - shython sound-reload splitvideo stdout swapout T teetime \ - timestamp tracefile transpose upsidedown vid \ - w4it-for-port-open whitehash wifi-reload wssh youtube-lbry \ - ytv yyyymmdd + shython sound-reload splitvideo stdout summer swapout T \ + teetime timestamp tracefile transpose twitsplit ctc upsidedown \ + vid w4it-for-port-open whitehash wifi-reload wssh \ + youtube-lbry ytv yyyymmdd all: 2search/2grep.1 2search/2search.1 blink/blink.1 \ burncpu/burncpu.1 bwlimit/bwlimit.1 clipboard/clipboard.1 \ @@ -22,10 +22,10 @@ all: 2search/2grep.1 2search/2search.1 blink/blink.1 \ seekmaniac/seekmaniac.1 shython/shython.1 \ sound-reload/sound-reload.1 splitvideo/splitvideo.1 \ stdout/stdout.1 teetime/teetime.1 timestamp/timestamp.1 \ - tracefile/tracefile.1 transpose/transpose.1 T/T.1 \ - upsidedown/upsidedown.1 vid/vid.1 wifi-reload/wifi-reload.1 \ - wssh/wssh.1 youtube-lbry/youtube-lbry.1 ytv/ytv.1 \ - yyyymmdd/yyyymmdd.1 + tracefile/tracefile.1 transpose/transpose.1 \ + twitsplit/twitsplit.1 T/T.1 upsidedown/upsidedown.1 vid/vid.1 \ + wifi-reload/wifi-reload.1 wssh/wssh.1 \ + youtube-lbry/youtube-lbry.1 ytv/ytv.1 yyyymmdd/yyyymmdd.1 %.1: % pod2man $< > $@ diff --git a/vid/vid b/vid/vid index fd83a35..0fbabcb 100755 --- a/vid/vid +++ b/vid/vid @@ -176,11 +176,10 @@ stdin() { } stdout() { - if [ -t 1 ] ; then - # STDOUT = terminal + if $stdout_is_terminal ; then # start $VIDEOPLAYER VIDEOPLAYER=${VIDEOPLAYER:-vlc --} - if tty -s ; then + if $stdin_is_terminal ; then # STDIN is terminal => limit to 100 shuf | parallel --halt now,done=1 --lb -n100 -Xj1 $VIDEOPLAYER else @@ -191,6 +190,18 @@ stdout() { fi } +if [ -t 1 ] ; then + stdout_is_terminal=true +else + stdout_is_terminal=false +fi + +if tty -s ; then + stdin_is_terminal=true +else + stdin_is_terminal=false +fi + stdin | G "$@" | stdout exit $?