whileループ後に「予期しないファイルの終わり」が発生する[閉じる]

whileループ後に「予期しないファイルの終わり」が発生する[閉じる]

私のOpenbox自動起動ファイルの完全な内容は次のとおりです。

# Compositor
picom &

# Korean input
ibus-daemon -dr &

# Screensaver
xscreensaver -no-splash &

# Wallpaper
while true; do
    nitrogen --random --set-auto
    sleep 3600
end

picomしかし、ログインしたときにのみ正常に実行されるようです。

bash ~/.config/openbox/autostart端末で実行すると、次のように表示されます。

/home/max/.config/openbox/autostart: line 33: syntax error: unexpected end of file

だから私のwhileループに問題があるようですが、どうしますか?

ベストアンサー1

bashこの構文が元のBourneシェルと同様に、ループwhileは次のように始まりますdone

# Wallpaper
while true; do
    nitrogen --random --set-auto
    sleep 3600
done

シェルはwhileループの始まりを探し、前方に読んでループの終わりを探します。終了キーワードを見つける前に、ファイルの終わりに達して文句を言いdoneます。したがって、「予期しないファイルの終わり」が発生します。

おすすめ記事