LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-16-2010, 08:33 PM   #1
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,445

Rep: Reputation: 83
command line options. How are they parsed when incompatible ones exist?


Hya,

Please excuse this extremely basic question.

Question is
When incompatible command line options exist, how are they parsed?

It looks like that
Code:
rm -f -i trash.*
behaves like
Code:
rm -i trash.*
So far, it looks like that options are parsed from left to right and right one overrides. But
Code:
ssh -v -v -v penguin@antarctica.the_earth
reads differently.

Is there any rule? (in POSIX, Linux, BSD, sparc, or unix?????)

Happy Penguins!
 
Old 02-16-2010, 09:40 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
I would simply try to think thru how I might try to write it....I visualize flags being set, with rules for what happens if there is a conflict. In principle, the parser would not care about the order of the options, as all the checking would be done just before execution.

And, you can;
--experiment
--read the source code
 
Old 02-16-2010, 09:53 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949
I'm not a programming expert, but no doubt it's up to the individual program/programmer(s). Probably most programs use some form of getopt to parse the command string, in the order given, but then it's the programmer's job to decide what to do with the options that it finds. The easiest solution is usually to simply let later settings override earlier ones, but depending on what the options are supposed to do, that isn't always the smart thing.
 
  


Reply

Tags
command, line, options


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with command line options jaepi Linux - Newbie 7 04-29-2007 07:26 PM
Grep's line numbers parsed into one line of output. judgex Programming 8 08-14-2006 04:22 AM
Command Line Options AUSanders79 Linux - Software 8 03-10-2005 10:24 AM
Help with command line options(ksh) SeT Programming 2 11-29-2004 06:54 PM
Command Line Options in C++ crichards Programming 5 03-08-2003 03:42 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration