How to conveniently specify a long line of command options?

Programming, for all ages and all languages.
Post Reply
Vonigol
Posts: 5
Joined: Mon Dec 17, 2007 4:14 am

How to conveniently specify a long line of command options?

Post by Vonigol »

Hello!

I am hooking GRUB bootloader's built-in commands. When I use GRUB's "./configure" to rebuild GRUB, I need to specify a lot of options in the command line. This is very inconvenient. Is there any way to type those options in some text file and then use it together with ./configure?

Some examples.

Lets "options.txt" be the file with the command line options that I need to specify. For example, it will contain the following text:

--enable-protector-mode \
--enable-example-kernel \
--disable-reiserfs \
--disable-iso9660 \
--disable-ffs \
"CFLAGS=-g -fno-stack-protector"

I tried the following variants but without success:

1) $ ./configure 'cat options.txt'
2) $ ./configute $(cat options.txt)
3) cat options.txt | ./configure

configure either doesn't understand the backlash ('\') from 'options.txt' or doesn't like CFLAGS. If I copy the text from "options.txt" and then manually insert it immediately after "$ ./configure ", then everything works fine. For example, why doesn't variant number 3) work?

Can anyone help me?

Thanks.

Best regards,
Xela
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

How about using a bash script (.rc)? Clicky

Cheers,
Adam
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

"alias" might also help.
Every good solution is obvious once you've found it.
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Re: How to conveniently specify a long line of command optio

Post by blound »

Vonigol wrote: --enable-protector-mode \
--enable-example-kernel \
--disable-reiserfs \
--disable-iso9660 \
--disable-ffs \
"CFLAGS=-g -fno-stack-protector"
you need to space seperate them not newline, 'cat' does not understand \ to mean continue on the line
Vonigol wrote: 3) cat options.txt | ./configure
this puts the options on stdin of configure, not the command line

what you should do is space seperate the options ( put them on the same line ) then do

Code: Select all

./configure `cat options.txt`
notice these are ` not '
Vonigol
Posts: 5
Joined: Mon Dec 17, 2007 4:14 am

Thanks

Post by Vonigol »

Thanks everyone. All the advices turned to be useful and workable.
Post Reply