You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to check whether a task is running in a TTY in order to set relevant flags to a command (docker exec -i -t, for example).
But the only thing that seems to work for substitution is tty -s.
The other results are a little weird. test doesn't work in a sub-command.
And inside dynamic variables, nothing seems to work. Example task:
tty:
cmd: |- echo -n test stdin: ; test -t 1 && echo X \ ; echo -n test stderr: ; test -t 2 && echo X \ ; echo -n sub test stdin: ; echo $(test -t 1 && echo X) \ ; echo -n sub test stderr: ; echo $(test -t 2 && echo X) \ ; echo -n tty: ; tty -s && echo X \ ; echo -n sub tty: ; echo $(tty -s && echo X) \ ; echo "{{.TTY}}"interactive: truevars:
TTY:
sh: |- echo -n var test stdin: ; if [ -t 1 ]; then echo -n X; fi; echo ''; echo -n var test stderr: ; if [ -t 2 ]; then echo -n X; fi; echo ''; echo -n var tty: ; if [ $(tty -s) ]; then echo -n X; fi; echo '';
❯ task -s tty
test stdin:X
test stderr:X
sub test stdin:
sub test stderr:X
tty:X
sub tty:X
var test stdin:
var test stderr:X
var tty:
Not sure why we still get stderr without stdin, I'm not a terminal specialist.
The interactive option doesn't change anything.
So the best I could find is $(tty -s && echo flags). Is there any better way?
Is it possible to put that in a variable?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to check whether a task is running in a TTY in order to set relevant flags to a command (
docker exec -i -t
, for example).But the only thing that seems to work for substitution is
tty -s
.The other results are a little weird.
test
doesn't work in a sub-command.And inside dynamic variables, nothing seems to work. Example task:
Not sure why we still get
stderr
withoutstdin
, I'm not a terminal specialist.The
interactive
option doesn't change anything.So the best I could find is
$(tty -s && echo flags)
. Is there any better way?Is it possible to put that in a variable?
Beta Was this translation helpful? Give feedback.
All reactions