LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A point in syntax in GNU programs. (https://www.linuxquestions.org/questions/linux-newbie-8/a-point-in-syntax-in-gnu-programs-887022/)

stf92 06-18-2011 04:32 AM

A point in syntax in GNU programs.
 
Hi:

For some commands the command synopsis (syntax) is given like this:
command [a|b] [args ...]
I take mplayer (perhaps not GNU) to illustrate the point:
mplayer [cdda|cddb]://track[-endtrack][:speed][/device] [options]
mplayer [dvd|dvdnav]://[title|[start_title]-end_title] [options]

An item inside square brackets is optional. The pipe sign is the 'or' logical connective (disjunction). But then, what is [cdda|cddb]?
If optional, I can omit it: it makes no sense because there are more the one possible synopsis for the command line. Any clue?

grail 06-18-2011 04:57 AM

I am not sure I understand the question as you seem to have already answered it??

[] - optional

| - you can use this one or that one

[cdda|cddb] - both of these are optional but you can only use cdda OR cddb

Where is the confusion?

carltm 06-18-2011 05:51 AM

Quote:

Originally Posted by stf92 (Post 4389200)
But then, what is [cdda|cddb]?

That means you can use "mplayer", "mplayer cdda" or "mplayer cddb".
It's like you described it. The parts inside square braces are
optional, and items separated by pipes are mutually exclusive (in
other words you must pick exactly one item from the list).

stf92 06-18-2011 06:00 AM

Quote:

Originally Posted by carltm (Post 4389232)
That means you can use "mplayer", "mplayer cdda" or "mplayer cddb".

I think I now understand. My confussion arises from this: if I want to play either a CDDA or a CDDB, then I must use, among the many synopsis given by the manual, that stated in post #1. But if I do mplayer ://1 I get "Failed to open ://1". I should have inferred that Mplayer is thinking I am using another synopsis. Well... I understand my self, and that's the important thing. But I wouldn't have done it with you. Thanks.

Reuti 06-18-2011 02:06 PM

I don’t user mplayer, but shouldn't it be [(cdda|cddb)://] if it’s not optional but exactly one of cdda or cddb has to appear in combination with ://? Optional syntax would be [cdda://|cddb://].

stf92 06-18-2011 04:01 PM

The problem, if there is one, is that there are other synopsis. Take these two, for instance:
mplayer [options] [file|URL|playlist|-]
mplayer [options] file1 [specific options] [file2] [specific options]
In fact, neither cdda nor cddb is mandatory, as you can see from the example.

Reuti 06-18-2011 04:07 PM

Quote:

Originally Posted by stf92 (Post 4389576)
In fact, neither cdda nor cddb is mandatory, as you can see from the example.

Yes, but you complained about an error when you specify ://1. So, :// has to appear if and only if you request cdda or cddb in addition. The syntax of the orignal help implies indeed that :// has to be specified all the times.

stf92 06-18-2011 08:32 PM

You are right. My examples were misleading.


All times are GMT -5. The time now is 02:08 PM.