I'm doing a lab and can't understand this:
Kubectl has support for auto-completion allowing you to discover the available options. This is applied to the current terminal session with source <(kubectl completion bash)
The cmd:
source <(kubectl completion bash)
sources-in what?
CodePudding user response:
source
(synonym for.
) is a bash built in command which executes the given file in the current shell environment<(command ...)
is process substitution - the output of the commands are passed as a file- bash completion is implemented with shell functions, which must be set in the current shell environment
- You can view the code that's executed to set up the completion functions:
kubectl completion bash
CodePudding user response:
Read and execute the generated completion script (kubectl completion bash) in your current shell.
CodePudding user response:
Using source, it runs within the existing shell, any variables/functions created or modified will remain available after the command completes.
In contrast you just run just the command, then a separate subshell would be spawned to run the command. When the command ends, you will not see the variables/functions in the current shell.
<( expression )
will attach the output of expression
to the stdin of an application/program.
So the command will run kubectl completion bash
within the existing shell instead of a separate subshell.