Subshell - CI/CD用語集の定義
subshell は、コマンドを ( ... ) で囲む、pipeline、または command substitution によって作られる子 shell の process です。その内部での変数の変更は親 shell には影響しません。
CI での扱い
よくある落とし穴: cmd | while read line; do VAR=$line; done は VAR を subshell 内で設定するため、後で VAR は空になります。pipe の各段はそれぞれ独自の subshell で実行されるので、そこで設定された状態は pipeline が終わると失われます。
関連ガイド
Shell - CI/CD Glossary DefinitionShell: A shell is the command interpreter that reads commands, expands variables and globs, and launches proc…
Pipe - CI/CD Glossary DefinitionPipe: A pipe (`|`) connects the standard output of one command to the standard input of the next, letting sma…
Command Substitution - CI/CD Glossary DefinitionCommand Substitution: Command substitution replaces `$(command)` (or backticks) with that command output, let…