LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-10-2003, 05:09 AM   #1
usernamed
LQ Newbie
 
Registered: Jun 2003
Location: By the sea
Distribution: LFS/BLFS
Posts: 24

Rep: Reputation: 15
Question Shell script problems, passing options to gcc


Hi,

I'm trying to create a tiny script that passes command line options to gcc when I'm working with GCC. The script is as follows:

#!/bin/bash
# cmpl - Script to compile .c source files
gcc "$CFLAGS" "$1".c -o "$1".o

This script works when $CFLAGS is only one option, for instance:

"-O2"

but fails whenever a second option is included, such as:

"-O2 -pipe"

giving the message: "cc1: invalid option '-O2 -pipe'

The combination above works when I type it at the command line. I'm confused. Any help would be much appreciated.

Mark
 
Old 09-10-2003, 06:16 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
no double quotes, by the looks of your script you seem to think bash variables need to be in double quotes, they dont apart from special cases. you also might want to look into makefiles, a much better way to do this than a script.
 
Old 09-10-2003, 06:47 AM   #3
usernamed
LQ Newbie
 
Registered: Jun 2003
Location: By the sea
Distribution: LFS/BLFS
Posts: 24

Original Poster
Rep: Reputation: 15
Thanks for your help,

I've looked at the thread that you need some help with, but I'm afraid I'm out of my depth.

Sorry I can't return the favour.

Mark
 
  


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
Passing parameters to a shell script neocookie Linux - General 5 10-20-2005 11:44 AM
passing parameters to functions in shell script kushalkoolwal Programming 1 09-28-2005 02:40 PM
Passing arguments to a shell script subu_s Programming 3 09-02-2005 05:13 AM
Passing variables from AWK script to my shell script BigLarry Programming 1 06-12-2004 04:32 AM
passing quotes in shell script Tenor Trombone Programming 1 04-18-2001 09:26 PM

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

All times are GMT -5. The time now is 02:50 AM.

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