Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


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

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


Please excuse this extremely basic question.

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

It looks like that
rm -f -i trash.*
behaves like
rm -i trash.*
So far, it looks like that options are parsed from left to right and right one overrides. But
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
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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;
--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: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
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.


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 > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:31 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