CshスクリプトのSHELLが/bin/shを指しているのはなぜですか?

CshスクリプトのSHELLが/bin/shを指しているのはなぜですか?

はい、Cシェルが悪いことを知っています。いいえ、Cシェルを選択していません。はい、私は適切なケースを使用することを好みます。いいえ、より良いシェルに切り替えることはできません。

非常に単純なスクリプトがあります。

/tmp/env_test.csh

#!/bin/csh -f

env

tcshシェルを使用してログインしたユーザーからこのスクリプトを実行した場合とSHELL同じです/bin/tcsh。 cronでこのスクリプトを実行した場合とSHELL同じです/bin/sh

SHELLが正しく更新されないのはなぜですか?この問題を解決するにはどうすればよいですか?

ベストアンサー1

調査man 1 csh。このセクションには、Pre-defined and environment variables定義または従う変数がリストされていますcsh。小文字の変数がありますshell

     shell      The file in which the shell resides.  This variable is used in
                forking shells to interpret files that have execute bits set,
                but which are not executable by the system.  (See the descrip-
                tion of Non-builtin Command Execution below.)  Initialized to
                the (system-dependent) home of the shell.

それでは、見てみましょう:

% echo $shell
/bin/csh

おすすめ記事