Jump to content

99 Bottles of Beer/Shell: Difference between revisions

→‎{{header|UNIX Shell}}: Make bash/ksh/zsh version more idiomatic
(→‎{{header|UNIX Shell}}: Make bash/ksh/zsh version more idiomatic)
Line 276:
<lang bash>bottles() {
beer=$1
[ $(( beer)) -gt> 0 ])) && echoprintf -n'%d' $beer || echo -nprintf "No more"
echo -nprintf " bottle"
[ $((beer)) -ne!= 1 ])) && echo -nprintf "s"
echo -nprintf " of beer"
}
 
for ((i=99;i>=0;i--)); do
((remaining=i))
echoprintf '%s on the wall\n' "$(bottles $remaining) on the wall"
echoprintf '%s\n' "$(bottles $remaining)"
if [ $(( remaining)) -eq== 0 ])); then
echoprintf "'Go to the store and buy some more"\n'
((remaining+=99))
else
echoprintf "'Take one down, pass it around"\n'
((remaining--))
fi
echoprintf '%s on the wall\n\n' "$(bottles $remaining) on the wall"
echo
done</lang>
 
1,480

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.