スクリプトで開かれたシェルを終了するには?

スクリプトで開かれたシェルを終了するには?

私はRaspberry Piのインストールと設定を自動化するスクリプトを書いています。私の問題は公式のインストールスクリプトにあります。ああ、新しいシェル(zsh)を開きます。これにより、私のスクリプトが効果的に終了し、追加の構成に別々のスクリプトが必要になります。私のスクリプトを含めたいです。オムズinstall.sh が完了しました。

スクリプト:

. ./functions.sh
echo "\n###### install zsh ######\n"


log "apt-get install -qqy zsh"

read -p "Enter Your Name: "  username
log "chsh -s /bin/zsh $username"

# this install.sh opens zsh and blocks proceeding of script
su - $username -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# I want the script to continue here
echo "More commands"

メモ:

  • Logはfunction.shで宣言され、コマンドを実行して実行されたコマンドを出力します。

ベストアンサー1

インストーラを実行する前に no に設定するか、RUNZSH端末に接続されていない標準入力を使用して実行すると、シェルは実行されません。あなたの場合、< /dev/nullコマンドの最後に感触を追加するのが最も簡単な解決策です。

su - $username -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" < /dev/null'

おすすめ記事