Skip to content

Commit 20e372f

Browse files
committed
handle pipe
1 parent 533a2c0 commit 20e372f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

kubectl-node_shell

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ generator=""
66
node=""
77
namespace=""
88
cmd='[ "nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid", "--", '
9-
custom=""
9+
custom=false
10+
if ! [ -p /dev/stdin ] && ! [ -p /dev/stdout ]; then
11+
tty=true
12+
else
13+
tty=false
14+
fi
1015
while [ $# -gt 0 ]; do
1116
key="$1"
1217

@@ -39,14 +44,14 @@ while [ $# -gt 0 ]; do
3944
node="$1"
4045
else
4146
cmd+="\"$1\", "
42-
custom=1
47+
custom=true
4348
fi
4449
shift
4550
;;
4651
esac
4752
done
4853

49-
if [ "$custom" = 1 ]; then
54+
if [ "$custom" = true ]; then
5055
cmd="$(echo "$cmd" | awk '1' RS=', \n') ]"
5156
else
5257
cmd+='"bash", "-l" ]'
@@ -79,7 +84,7 @@ overrides="$(
7984
"name": "nsenter",
8085
"stdin": true,
8186
"stdinOnce": true,
82-
"tty": true,
87+
"tty": $tty,
8388
"command": $cmd
8489
}
8590
],

0 commit comments

Comments
 (0)