99 bottles of beer: Difference between revisions

Content deleted Content added
→‎{{header|Scratch}}: This image is too wide. Use some CSS "overflow: auto;" to insert a horizontal scroll bar. Works with Firefox.
→‎{{header|UNIX Shell}}: Tweak Bourne Shell to output complete verses. Add C Shell.
Line 4,015: Line 4,015:


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
{{works with|POSIX shells}}
{{works with|Bourne Shell}}
<lang bash>#!/bin/sh
<lang bash>#!/bin/sh


i=99
i=99 s=s


while [ $i -ge 0 ]; do
while [ $i -gt 0 ]; do
if [ $i -gt 1 ] || [ $i -eq 0 ]; then
s="s"
else
s=""
fi
echo "$i bottle$s of beer on the wall"
echo "$i bottle$s of beer on the wall"
if [ $i -ne 0 ]; then
echo "$i bottle$s of beer
echo "$i bottle$s of beer
Take one down, pass it around"
Take one down, pass it around"
# POSIX allows for $(( i - 1 )) but some older Unices didn't have that
fi
# POSIX allows for $(( $i - 1 )) but some older Unices didn't have that
i=`expr $i - 1`
i=`expr $i - 1`
[ $i -eq 1 ] && s= || s=s
done
echo "$i bottle$s of beer on the wall
</lang>
"
done</lang>


{{works with|Bash}}
{{works with|Bash}}
Line 4,059: Line 4,054:
echo
echo
done</lang>
done</lang>

==={{header|C Shell}}===
<lang csh>@ i=99
set s=s
while ($i > 0)
echo "$i bottle$s of beer on the wall"
echo "$i bottle$s of beer"
echo "Take one down, pass it around"
@ i = $i - 1
if ($i == 1) then
set s=
else
set s=s
endif
echo "$i bottle$s of beer on the wall"
echo ""
end</lang>


=={{header|UnixPipes}}==
=={{header|UnixPipes}}==