ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've got this prototype program I'm working on. However I keep getting a syntax error on line 124. I don't see anything wrong, but it says there is an unexpected token "}". Meaning it doesn't see that the "}" is the end of a function.
Code:
#! /bin/bash
function Menu()
{
read -p "Create a new character? [y/n]" ans
case "$ans" in
"y" | "Y")main;;
"n" | "N")Quit;;
*)echo "Enter y/n"
Menu;;
esac
}
function RCC()
{
echo -n "What spiecies is the character?
1)Human"
read -p species
case $species
in
1)OCC;;
*) echo "Please pick a valid option"
RCC
;;
esac
}
function OCC()
{
echo -n "Pick an occupation
1. Cyborg
2. Deadboy
3. Wilderness Scout
4. Mercenary"
read -p occupation
case $occupation in
1)Cyborg;;
2)Deadboy;;
3)WS;;
4)Merc;;
*)echo "Please pick a valid option"
OCC
;;
esac
}
function Cyborg()
{
IQ=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
ME=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
MA=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PS=30
PE=25
PP=10
HP=0
SDC=250
}
function Deadboy()
{
IQ=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
ME=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
MA=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PS=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PE=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PP=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
HP=$((`/bin/D6` + $PE))
}
function WS()
{
IQ=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
ME=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
MA=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PS=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PE=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PP=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
HP=$((`/bin/D6` + $PE))
SDC=$((`/bin/D6` + `/bin/D6`)) + $PE ]
}
function Merc()
{
IQ=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
ME=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
MA=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PS=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PE=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
PP=$((`/bin/D6` + `/bin/D6` + `/bin/D6`))
HP=$((`/bin/D6` + $PE))
SDC=$((`/bin/D6` + `/bin/D6`)) + $PE ]
}
function Print()
{
echo -n $IQ
echo -n $ME
echo -n $MA
echo -n $PS
echo -n $PE
echo -n $PP
echo -n $HP
echo -n $SDC
Return2Menu
}
function Return2Menu()
{
read -p "Return to main menu? [y/n]" ans
case $ans
in
"y" | "Y")Menu;;
"n" | "N")Leave;;
*) echo "Enter y/n"
Return2Menu;;
}
function Leave()
{
exit
}
Menu
If anyone can tell me what I missed or what I have extra, thank you.
I knew it was something really stupid. Thanks I feel a lot better.
I have another problem. I changed the first function, I simplified it down to a simple Y/N, only uppercase Y and N. But that's not the problem. I've got the program to run up to the point that it asks occupation. After entering any thing it dumps me back to the command-line. I can't see way it does that, it doesn't even give me an error.
I don't see where you ever have a function named "main" or "Quit" so it would bomb at both y(es) and n(o) as these don't aren't "commands". (Unless you have something named "main" or "Quit" in your $PATH.)
You should see a message like:
<scriptname>: line 7: main: command not found
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.