Why the slash? 
Author Message
 Why the slash?

Why did the convention to use slashes to mark command line options?
Given the way C parses argv[] it seems an extra step to check for the
leading slash. Is there a C function that handles the slashes? I check
the zeroth element for a slash then look to the first element for the
command option. Why not just the argument letter instead of the
slash-letter combination? Just wondering where and why the slash
convention started.



Thu, 06 Jan 2000 03:00:00 GMT  
 Why the slash?

Quote:

>Why did the convention to use slashes to mark command line options?

What convention? Command line options are marked with dashes, not
slashes ;-)

Quote:
>Given the way C parses argv[] it seems an extra step to check for the
>leading slash.

Well, using _some_ character may be usefull do distinguish between
options and arguments.

Quote:
>Is there a C function that handles the slashes? I check
>the zeroth element for a slash then look to the first element for the
>command option. Why not just the argument letter instead of the
>slash-letter combination? Just wondering where and why the slash
>convention started.

Ask in a newsgroup that deals with an OS that useses slashes.

Kurt

--
| Kurt Watzka                             Phone : +49-89-2180-6254



Fri, 07 Jan 2000 03:00:00 GMT  
 Why the slash?



Quote:
>Why did the convention to use slashes to mark command line options?
>Given the way C parses argv[] it seems an extra step to check for the
>leading slash.

If you are referring to DOS's COMMAND.COM this has nothing to do with
C, it is simply the way Microsoft decided to format command line options
in DOS.

Quote:
>Is there a C function that handles the slashes?

None that I an aware of. In what way would you want them "handled"?

Quote:
>I check
>the zeroth element for a slash then look to the first element for the
>command option. Why not just the argument letter instead of the
>slash-letter combination? Just wondering where and why the slash
>convention started.

To distinguish it as a command option rather than something else. For example

XCOPY A:V V

under your scheme would the final argument mean the filename V or the
option /V ? However this is really a DOS related issue.

--
-----------------------------------------


-----------------------------------------



Fri, 07 Jan 2000 03:00:00 GMT  
 Why the slash?

Quote:

> Why did the convention to use slashes to mark command line options?
> Given the way C parses argv[] it seems an extra step to check for the
> leading slash. Is there a C function that handles the slashes? I check
> the zeroth element for a slash then look to the first element for the
> command option. Why not just the argument letter instead of the
> slash-letter combination? Just wondering where and why the slash
> convention started.

  I think the dash convention started in Unix, where people wanted to
distinguish between the command line options and the arguments of these
options.  You check the kth element (k>0) for a command option (there
may be several options after one dash), and then, if your option has
arguments, you check if there is something else after this element.  If
not, look at the next word of the options.  E.g. in the command "cc -go
tst tst.c tst2.c" the compiler is asked to put the executable into
"tst", and it's equivalent to "cc -gotst tst.c tst2.c" or "cc -g -o tst
tst.c tst2.c".  Another example is using the dash itself as an argument,
like in "tar -xvf -" which looks at stdin instead of the input file.
  Most humans read whole sentences, and not left-to-right, so a command
where every option is easily parseable in itself is more
comprehensible.  The standard convention is that an argument without
dash is a file name.
  If your program uses only a simple set of options, you can omit
sl/dash,like in the "ps" command on Unix, where you can use "ps aux" or
"ps -u your-name".

  Michael



Fri, 07 Jan 2000 03:00:00 GMT  
 Why the slash?

Quote:
>Why did the convention to use slashes to mark command line options?

I don't know what prompted Microsoft to use the forward slash as a delimiter
for command line switches, but they had to use something. UNIX uses a dash, why
not a slash for DOS/Windows? Any tokens preceding the slash are assumed to be
arguments upon which a command is to operate; the slash clearly separates
command line switches which are used to customize the actions of the command.

Quote:
>Given the way C parses argv[] it seems an extra step to check for the
>leading slash. Is there a C function that handles the slashes? I check

I guess you are referring to the use of s <space> as delimiter between command
line arguments. 'C' can not differentiate between a command line argument and a
switch. so, if you choose to implement switches, it is up to you to provide the
needed parsing.

Quote:
>the zeroth element for a slash then look to the first element for the
>command option. Why not just the argument letter instead of the
>slash-letter combination? Just wondering where and why the slash
>convention started.

To allow batch operation of programs by passing switches to tell the command
what to do without prompting the user, I would guess. Plus, how would you know
where the switches started?

Regards,
Greg DiGiorgio



Fri, 07 Jan 2000 03:00:00 GMT  
 Why the slash?


Quote:

>Why did the convention to use slashes to mark command line options?

What slash convention? In UNIX, dashes are used. Slashes are a DOS thing.

Quote:
>Given the way C parses argv[] it seems an extra step to check for the
>leading slash. Is there a C function that handles the slashes? I check
>the zeroth element for a slash then look to the first element for the
>command option. Why not just the argument letter instead of the
>slash-letter combination? Just wondering where and why the slash
>convention started.

The convention started due to a need to have a delimiter which means
that what follows is an option rather than the name of a file.

Many UNIX commands omit the requirement for a dash, because options are
always required and are always the first argument. For example:

        tar xvf file.tar

rather than

        tar -xvf file.tar

to extract a given tar file with verbose output.



Fri, 07 Jan 2000 03:00:00 GMT  
 Why the slash?

Quote:

>>Why did the convention to use slashes to mark command line options?
>I don't know what prompted Microsoft to use the forward slash as a delimiter
>for command line switches, but they had to use something. UNIX uses a dash, why

Afaik, the '/' derives from CP/M, an older OS, where it was used to mark
switches. This also could be the reason why we have to deal with the '\' as a
path-separator in DOS.

   Rozen verwelken,           \--------------------\
   Schepen vergaan.             \ Jan van den Broek  \

   Een paard moet je slaan.         \--------------------\



Sat, 08 Jan 2000 03:00:00 GMT  
 Why the slash?



Quote:

>>Why did the convention to use slashes to mark command line options?

>What convention? Command line options are marked with dashes, not
>slashes ;-)

Ping!
UNIX user detected :)

You can tell UNIX users, because they don't do-it /likethis, they do-it
-likethis.

Quote:

>>Given the way C parses argv[] it seems an extra step to check for the
>>leading slash.

>Well, using _some_ character may be usefull do distinguish between
>options and arguments.

>>Is there a C function that handles the slashes? I check
>>the zeroth element for a slash then look to the first element for the
>>command option. Why not just the argument letter instead of the
>>slash-letter combination? Just wondering where and why the slash
>>convention started.

>Ask in a newsgroup that deals with an OS that useses slashes.

Better still, ask in a newsgroup that deals with OSes!
C is C whereever you go (well, ANSI C is..) - comp.lang.c is about C,
not DOS, UNIX, NT, Be, TrekOS or NeXT.

--
Revised anti-spam in use : remove X to reply -
'Xnetbook' becomes 'netbook'

Anti-spam thermonuclear warheads cheap at only $300!



Sat, 08 Jan 2000 03:00:00 GMT  
 Why the slash?


Quote:
>Afaik, the '/' derives from CP/M, an older OS, where it was used to mark
>switches. This also could be the reason why we have to deal with the '\' as a
>path-separator in DOS.

Last time I looked DOS could use either form of slash '/' and '\' in path
names.  Just COMMAND.COM had a little problem as '/' is the switch character.
There also used to be a way to change this switch character to fx. '-'.
By the time DOS rel2 came out MS had alread done a lot of work with xenix
so you might be able to guess where the useage of slash in path name came
from.     Sorry nothing to do with c language.

Villy



Sun, 09 Jan 2000 03:00:00 GMT  
 Why the slash?

Quote:

>>Why did the convention to use slashes to mark command line options?

>I don't know what prompted Microsoft to use the forward slash as a delimiter
>for command line switches, but they had to use something. UNIX uses a dash, why
>not a slash for DOS/Windows? Any tokens preceding the slash are assumed to be
>arguments upon which a command is to operate; the slash clearly separates
>command line switches which are used to customize the actions of the command.

MS-DOS inherited the "/" for options from earlier DEC systems
Unix inherited the "-" for options from Multics.


Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. string method for slashes in file paths ?

2. ANNOUNCE:New C/C++ tool slashes development time

3. New C tool slashes development time

4. Slash Screen Component With DevStudio

5. Date and Slashes

6. why, Why, WHY

7. Why oh Why can no one help me..

8. Interface IDs - why oh why??

9. I have to read in two files - one is fixed positioned, the other delimited by slashes.

10. Why? Why? Why? ATL Component not registering

11. WHY? WHY? WHY?

12. WHY? WHY? WHY?

 

 
Powered by phpBB® Forum Software