Bash Function Syntax Error Unexpected

Contents

Browse other questions tagged bash shell ubuntu shell-script or ask your own question. msseverAugust 2nd, 2008, 09:01 PMThanks for the suggestions. I noticed either function style will work fine on OS X. script.sh: line 50: unexpected EOF while looking for matching `"' script.sh: line 100: syntax error: unexpected end of file This one indicates the double-quote opened in line 50 does not have navigate to this website

Several possible fixes: Reinstall bash: sudo aptitude reinstall bash Upgrade to Hardy Download the bash source package, bump the version number, build the package, and install it. UNIX is a registered trademark of The Open Group. Also, I see that later on you use commas to separate arguments (MoveToTarget $SourcePath, $DestPath). Problem?

Bash Syntax Error Unexpected Token

The question does not have to be directly related to Linux and any language is fair game. This server was installed with Ubuntu 7.10 server 64-bit. Alias expansion happens before the real language interpretion, thus the alias is expanded and makes your function definition invalid. I'm not sure what syntax you need to use in /bin/sh, but I would start by trying simple backticks in place of the $( and ).

I guess I'll have to read up on dash, bash and sh to understand the difference between the different shells. Bash Syntax Error Unexpected End Of File Thanx. #!/bin/bash color_def="~/.colorrc" if -f $color_def; then . $color_def else # color definitions black="$(tput setaf 0)" darkgrey="$(tput bold ; tput setaf 0)" lightgrey="$(tput setaf 7)" white="$(tput bold ; tput setaf 7)" I still have to manually edit some files for use plugins on TeXmacs editor, and they are the officially supported ones :( It was by then very common to replace that When you run it using ./ it will use the shell you mention on first line, in your case: #!/bin/sh if you do a ls -l /bin/sh you will see that

Unfortunately, Bash doesn't disable all its extensions when running in sh mode. Bash Syntax Error Near Unexpected Token Done' Do COB LEDs usually need electrically insulating from the heatsink? Both bash and dash are essential packages, which means that you shouldn't be able to mess with them without a big warning. in the very first line of a script.

Bash Syntax Error Unexpected End Of File

some code ... I can't find the actual bash shell anywhere. Bash Syntax Error Unexpected Token if [ "$USER" = bozo ] then bozo_greet () # Function definition embedded in an if/then construct. { echo "Hello, Bozo." } fi bozo_greet # Works only for Bozo, and other Syntax Error Unexpected End Of File Bash Script Is 8:00 AM an unreasonable time to meet with my graduate students and post-doc?

The body of the function is the compound command compound-command (see Compound Commands above) luvshines View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts useful reference For future reference, though, only use POSIX syntax in scripts that start with a #!/bin/sh shebang, and use #!/bin/bash for scripts that contain Bash-specific syntax. Password Protected Wifi, page without HTTPS - why the data is send in clear text? Meaning of Guns and ghee Should indoor ripened tomatoes be used for sauce? Bash Syntax Error Redirection Unexpected

msseverAugust 2nd, 2008, 05:59 AMOn my system, I removed the /bin/sh link to dash, and changed it to point to /bin/bash. Not the answer you're looking for? Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the my review here This site is not affiliated with Linus Torvalds or The Open Group in any way.

The output would look like this when you trace code outside a function: +(somefile.bash:412): echo 'Hello world' …and like this when you trace code inside a function: +(somefile.bash:412): myfunc(): echo 'Hello maybe dash create it by default if bash it's not installed) You can rm the symlink and install bash: sudo rm /bin/bash sudo apt-get install bash hth madams11August 2nd, 2008, 08:20 I do know that /bin/bash is a symbolic link to /bin/dash at the moment. Bash Syntax Error Near Unexpected Token (' Ubuntu not_empty () { : } # Contains a : (null command), and this is okay. # Thank you, Dominick Geyer and Thiemo Kellner.

The Bourne Shell (sh) is specified in POSIX as the standard shell for portable scripts. Good way to explain fundamental theorem of arithmetic? But interestingly, on the correct arch the file beginning with #! /bin/sh executed perfectly. get redirected here same damn error.

Functions are called, triggered, simply by invoking their names. On solaris (in sh) you can not use the function keyword either... Was running wrong arch executable.

These unmatched errors occur with: double-quote pairs single-quote pairs (also $'string'!) missing a closing } with parameter expansion syntax Too many arguments bash: test: too many arguments You most likely forgot I used bash regenerate-makefiles.sh and the script ran perfectly. See also Discussion Debugging a script These few lines are not intended as a full-fledged debugging tutorial, but as hints and comments about debugging a Bash script. I do know that /bin/bash is a symbolic link to /bin/dash at the moment.

Then ensure that the it is indeed installed, and if not, install it. Please click the link in the confirmation email to activate your subscription. There is nothing about this line running as sudo that should stop it working to my knowledge, does anyone have any ideas? Problem?

asked 5 years ago viewed 3561 times active 7 months ago Related 2882Can a Bash script tell which directory it is stored in?729How do I parse command line arguments in bash?310How That is also a problem. bash syntax share|improve this question edited Jul 9 '12 at 13:04 Amith KK 6,8241046103 asked Jul 9 '12 at 2:05 WASasquatch 1915 add a comment| 1 Answer 1 active oldest votes So, either you run: bash regenerate-makefiles.sh or replace first line with: #!/bin/bash (or even remove the 1st line and environment will call it with bash) or (losing generality) adapt it for

I am also getting Syntax error: "(" unexpected The problem is, I was NOT getting it an hour ago! Based on the answer you've chosen to this question, you can see that invoking the script directly with /bin/bash will cause Bash to interpret your script, with no problems. asked 3 years ago viewed 2184 times active 3 years ago Related 17How to execute shell script via crontab?1user crontabs don't work, only /etc/crontab0Run a shell script using cron2Crontab not working