LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 02-17-2011, 05:02 PM   #1
debsys07
Member
 
Registered: Mar 2007
Posts: 46

Rep: Reputation: 16
Question Bash script syntax different for Ubuntu(Lucid)?


In a bash script brought over from a Debian/Lenny system, Ubuntu 10.04 stumbles on the left parenthesis in the expression below:

NEED_COLS=$[($HEX_WIDTH * 4) + 12]

Is it an Ubuntu/Debian script style mismatch, or just post-Lenny? If that can be answered, is there a way to reconcile or syntax check older scripts?

Thx,
Ron
 
Old 02-17-2011, 05:07 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
It runs correctly in GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)

Are you sure you are running Bash as your shell? I bet you are running Dash, which indeed gives this error. You can overcome that by explicitly running /bin/bash yourscript, or change #!/bin/sh to #!/bin/bash, or set bash as your default shell instead of dash.

jlinkels
 
Old 02-17-2011, 05:45 PM   #3
debsys07
Member
 
Registered: Mar 2007
Posts: 46

Original Poster
Rep: Reputation: 16
Well, you're just all over my problems today. This is the 2nd one you've answered. Glad you're out there!

Funny, under Lenny, I had #!/bin/sh on all my scripts (partly from inheriting the code), but they ran "bash-wise." I'm not at the machine with Ubuntu today, but I'm pretty sure bash is my default shell there as well. At least the .bash* scripts get run at login.

Anyway, I'll check out the native shell theory tomorrow.

Thx again!
Ron
 
  


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
SED in BASH Script - Syntax Problem stlouis Programming 4 01-13-2008 10:38 AM
Bash script syntax error snowman81 Programming 5 11-16-2007 02:35 AM
How to check the bash script syntax? mesh2005 Linux - General 2 04-23-2006 08:22 AM
BASH - simple script issue - syntax? tw1ggy5 Programming 11 05-21-2004 09:09 AM
help with basic syntax in bash script Supp0rtLinux Linux - Software 4 03-27-2003 06:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 03:00 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