Download your favorite Linux distribution at LQ ISO.
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 04-18-2001, 11:35 AM   #1
Tenor Trombone
LQ Newbie
Registered: Apr 2001
Posts: 1

Rep: Reputation: 0


I have a program that REQUIRES a comment to be provided when the program is invoked. But 9 times out of 10 my comment is an empty string. The comment is specified using the '-c' switch on the program's command line.

For example:

ci -c "this izza comment"

OK - now here's what I'd like to accomplish:

Basically, I'd like a front end script, call it cinew, that effectively makes the '-c' switch be optional. So, if I enter:


it invokes 'ci' as follows:

ci -c ""

And, if I use '-c', such as:

cinew -c "unother test"

it simply invokes 'ci' as is.

The biggest problem is that the quotes around -c's argument are lost once I'm inside the cinew script. So if I do this at the command line:

cinew -c "abc def" xyz

and my 'cinew' script contains a line:

ci $*

it gets expanded to:

ci -c abc def xyz

which is interpretted as FOUR (not THREE) arguments by the 'ci' program.

There are additional (optional) switches supported by 'ci', so I can't just hard-code quotes into the script (for example, ci $1 "$2" $3), because I can't assume that $2 will always be the comment string.

I cannot figure out a simple way to preserve the quotes and pass them off to the 'ci' program within the shell script.

I tried 'set -f' before I ran 'cinew', but that didn't change anything.

My login shell is Bash, and the script is Bourne.

Thanks for any advice,
Andover, MA
Old 04-18-2001, 09:26 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Why cant you quote every parameter?

ci "$1" "$2" "$3" "$4"
ci "$@"



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
Shell script problems, passing options to gcc usernamed Programming 2 09-10-2003 06:47 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:41 PM.

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