theChauvinist
April 8th, 2005, 06:26 PM
I've just started learning shell scripting, and am writing a script which installs all the programs I regularly use (after asking for the users consent), for use on fresh installs. So far I've only included GCC and Firefox.
However, at the moment it doesn't work how I want it to; it gives the spaces to type y or n before it actually asks the question. This is probably a dumb question, but hey, I've never programmed before :-) .
#!/bin/bash
function aptget
{
for app in gcc mozilla-firefox; do
echo "Do you wish to install/update $app? [y/n]"
read answer
if [ "$answer" = "y" ]; then
apt-get install $app
else
echo "you have chosen not to install $app"
fi
done
}
echo $(aptget)
However, at the moment it doesn't work how I want it to; it gives the spaces to type y or n before it actually asks the question. This is probably a dumb question, but hey, I've never programmed before :-) .
#!/bin/bash
function aptget
{
for app in gcc mozilla-firefox; do
echo "Do you wish to install/update $app? [y/n]"
read answer
if [ "$answer" = "y" ]; then
apt-get install $app
else
echo "you have chosen not to install $app"
fi
done
}
echo $(aptget)