インタラクティブシェルをインタラクティブにするには?

インタラクティブシェルをインタラクティブにするには?

この質問は愚かに見えるかもしれませんが、netcat接続を介して愚かなシェルをアップグレードする方法を理解しようとしている間にこの質問に遭遇しました。

具体的には、特定のキーストロークがシェルの特定の動作をトリガーする原因について話しています。例:上矢印=前のコマンド、左矢印=左に1移動、消去=画面消去など...

ベストアンサー1

Bashの場合は、マニュアルページに次のように表示されます。

呼ぶ

   A login shell is one whose first character of argument zero is a -, or one
   started with the --login option.

   An interactive shell is one started without non-option arguments (unless -s is
   specified) and without the -c option whose standard input and error are both
   connected to terminals (as determined by isatty(3)), or one started with the -i
   option.  PS1 is set and $- includes i if bash is interactive, allowing a shell
   script or a startup file to test this state.

複数のシェルの起動ファイルで、次の対話テストを表示できます。

if [ "$PS1" ]; then
# set up for interactive use
fi

おすすめ記事