vid: Bug: stdin would never be detected as terminal.

This commit is contained in:
Ole Tange 2024-09-14 11:20:53 +02:00
parent 803cfd6433
commit 9890961c15
2 changed files with 22 additions and 11 deletions

View file

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

17
vid/vid
View file

@ -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 $?