Skip to content

Commit 9ac6923

Browse files
author
OpenShift Bot
authored
Merge pull request openshift#9529 from jwendell/TERM-cli
Merged by openshift-bot
2 parents 380a82a + 289b2e8 commit 9ac6923

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

docs/man/man1/oc-rsh.1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ This command will attempt to start a shell session in a pod for the specified re
2020
It works with pods, deployment configs, jobs, daemon sets, and replication controllers.
2121
Any of the aforementioned resources (apart from pods) will be resolved to a ready pod.
2222
It will default to the first container if none is specified, and will attempt to use
23-
'/bin/bash' as the default shell. You may pass an optional command after the resource name,
23+
'/bin/sh' as the default shell. You may pass an optional command after the resource name,
2424
which will be executed instead of a login shell. A TTY will be automatically allocated
25-
if standard input is interactive \- use \-t and \-T to override.
25+
if standard input is interactive \- use \-t and \-T to override. A TERM variable is sent
26+
to the environment where the shell (or command) will be executed. By default its value
27+
is the same as the TERM variable from the local environment; if not set, 'xterm' is used.
2628

2729
.PP
2830
Note, some containers may not include a shell \- use 'oc exec' if you need to run commands

docs/man/man1/openshift-cli-rsh.1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ This command will attempt to start a shell session in a pod for the specified re
2020
It works with pods, deployment configs, jobs, daemon sets, and replication controllers.
2121
Any of the aforementioned resources (apart from pods) will be resolved to a ready pod.
2222
It will default to the first container if none is specified, and will attempt to use
23-
'/bin/bash' as the default shell. You may pass an optional command after the resource name,
23+
'/bin/sh' as the default shell. You may pass an optional command after the resource name,
2424
which will be executed instead of a login shell. A TTY will be automatically allocated
25-
if standard input is interactive \- use \-t and \-T to override.
25+
if standard input is interactive \- use \-t and \-T to override. A TERM variable is sent
26+
to the environment where the shell (or command) will be executed. By default its value
27+
is the same as the TERM variable from the local environment; if not set, 'xterm' is used.
2628

2729
.PP
2830
Note, some containers may not include a shell \- use 'openshift cli exec' if you need to run commands

pkg/cmd/cli/cmd/rsh.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1212
"k8s.io/kubernetes/pkg/util/term"
1313

14+
"github.com/openshift/origin/pkg/cmd/util"
1415
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
1516
)
1617

@@ -24,9 +25,11 @@ This command will attempt to start a shell session in a pod for the specified re
2425
It works with pods, deployment configs, jobs, daemon sets, and replication controllers.
2526
Any of the aforementioned resources (apart from pods) will be resolved to a ready pod.
2627
It will default to the first container if none is specified, and will attempt to use
27-
'/bin/bash' as the default shell. You may pass an optional command after the resource name,
28+
'/bin/sh' as the default shell. You may pass an optional command after the resource name,
2829
which will be executed instead of a login shell. A TTY will be automatically allocated
29-
if standard input is interactive - use -t and -T to override.
30+
if standard input is interactive - use -t and -T to override. A TERM variable is sent
31+
to the environment where the shell (or command) will be executed. By default its value
32+
is the same as the TERM variable from the local environment; if not set, 'xterm' is used.
3033
3134
Note, some containers may not include a shell - use '%[1]s exec' if you need to run commands
3235
directly.`
@@ -145,5 +148,9 @@ func (o *RshOptions) Validate() error {
145148

146149
// Run starts a remote shell session on the server
147150
func (o *RshOptions) Run() error {
151+
// Insert the TERM into the command to be run
152+
term := fmt.Sprintf("TERM=%s", util.Env("TERM", "xterm"))
153+
o.Command = append([]string{"env", term}, o.Command...)
154+
148155
return o.ExecOptions.Run()
149156
}

0 commit comments

Comments
 (0)