LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2007, 01:57 PM   #1
Sparkfist
Member
 
Registered: Feb 2004
Location: Michigan
Distribution: Mint 20.1
Posts: 69
Blog Entries: 1

Rep: Reputation: 15
Need some debugging help


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.
 
Old 06-07-2007, 02:16 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Often when you see a complaint like this is instructive to go to the line in question then look at what happened ABOVE it:

Code:
Return2Menu;;
}

function Leave()
Your "case" isn't ending with "esac" as it should.
 
Old 06-07-2007, 02:48 PM   #3
Sparkfist
Member
 
Registered: Feb 2004
Location: Michigan
Distribution: Mint 20.1
Posts: 69

Original Poster
Blog Entries: 1

Rep: Reputation: 15
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.

Thanks again.
 
Old 06-08-2007, 08:41 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
I see in your original you have:

Code:
   "y" | "Y")main;;
   "n" | "N")Quit;;
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Debugging in C pranavojha Programming 11 03-10-2006 09:43 AM
Debugging Mercurius Programming 3 10-19-2005 02:59 PM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
debugging devit Programming 1 02-10-2004 11:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration