0
bashスクリプト(またはどの言語でも)がヘッドレスで実行されているかどうかを判断する方法はありますか?ユーザーが入力できるかどうかを知りたい彼らができるなら、私は彼らに何かを尋ねるつもりです。スクリプトは、ユーザーが入力できるかどうかをどのように知ることができますか?
bashスクリプト(またはどの言語でも)がヘッドレスで実行されているかどうかを判断する方法はありますか?ユーザーが入力できるかどうかを知りたい彼らができるなら、私は彼らに何かを尋ねるつもりです。スクリプトは、ユーザーが入力できるかどうかをどのように知ることができますか?
男のbashのから:
An interactive shell is one started without non-option arguments 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.
あなたは '-t'フラグに' [ '/' test'との接続のttyを確認することができます。 –
これはどのように広すぎますか? –
「bashスクリプト(または何でも)」はかなり広いです。また、「ヘッドレスウェイ」は、それ以上の明確化なしではかなり広いです。それは私が(bashのための)答えがかなり単純明快だと言った。 –