Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-10-2003, 05:09 AM   #1
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


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:

# 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:


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.

Old 09-10-2003, 06:16 AM   #2
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
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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:07 AM.

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