[comp.sys.ibm.pc] pathnames

nather@ut-emx.UUCP (Ed Nather) (02/10/89)

In article <662@mks.UUCP>, wheels@mks.UUCP (Gerry Wheeler) writes:
> If I may, I'd like to make a request of you software authors out there
> -- please write your programs so they will handle either type of slash
> in pathnames.  It would make life easier for many people. 

It would indeed.  Most of the MS-DOS utilities will accept either one,
but "subst" will not, and both MSC and Borland's linker demand backslashes.
A recent conversation about Borland's new debugger, which also demands
backslashes, got the helpful reply

"Well, OS2 doesn't allow it, so get used to backslashes."


-- 
Ed Nather
Astronomy Dept, U of Texas @ Austin

spolsky-joel@CS.YALE.EDU (Joel Spolsky) (02/10/89)

In article <662@mks.UUCP>, wheels@mks.UUCP (Gerry Wheeler) writes:
> If I may, I'd like to make a request of you software authors out there
> -- please write your programs so they will handle either type of slash
> in pathnames.  It would make life easier for many people. 


Actually I noticed that if you write your program with Turbo-C it
_will_ accept both kinds of slashes unless you do something to prevent
it.  Isn't that neat?

+----------------+----------------------------------------------------------+
|  Joel Spolsky  | bitnet: spolsky@yalecs.bitnet     uucp: ...!yale!spolsky |
|                | internet: spolsky@cs.yale.edu     voicenet: 203-436-1483 |
+----------------+----------------------------------------------------------+
                                                      #include <disclaimer.h>

sagen@nucthy.physics.orst.edu (Milt Sagen) (02/10/89)

In article <10353@ut-emx.UUCP> nather@ut-emx.UUCP (Ed Nather) writes:
>A recent conversation about Borland's new debugger, which also demands
>backslashes, got the helpful reply
>
>"Well, OS2 doesn't allow it, so get used to backslashes."
>

I've got to say this, it is nothing more than my opinion, so take it or leave
it.

Making the backslash character the directory separator was a stupid idea.  
Consider the fact that the backslash character is not located at any one place
between keyboards.  It is such a pain to go to a different machine with a 
different keyboard with a different location for the backslash yet running the
same operating system.


Milt Sagen                    Internet: sagen@nucthy.physics.orst.edu
Department of Physics
Oregon State University
Corvallis, OR  97331          Tele: (503) 754-4631

kiravuo@kampi.hut.fi (Timo Kiravuo) (02/10/89)

In article <8769@orstcs.CS.ORST.EDU> sagen@nucthy.PHYSICS.ORST.EDU (Milt Sagen) writes:
>Making the backslash character the directory separator was a stupid idea.  

It was a F***ing stupid idea. Microsoft is not very competent
even at their best, but this was one of their worst ideas. And
IBM has topped it. On the new 102 key Scandinavian keyboard the
backslash is generated by pressing right-Alt and the key right to
the 0 (+ in Scandinavia, - in the USA). Now how does the IBM
think that we type backslash, when _both_ keys needed to generate
it are on the right side of the keyboard. Absolutely idiotic. If
they have to redesign the keyboard, why coudn't they at least
have somebody to try to type on it. I mean, they have been making
typewriters for such a long time, that they must have heard about
touch-typing. 

Timo Kiravuo    90-451 4328
kiravuo@hut.fi  kiravuo@fingate.bitnet  opmvax::kiravuo

gbs@stratus.UUCP (George B. Smith) (02/11/89)

In article <10353@ut-emx.UUCP> nather@ut-emx.UUCP (Ed Nather) writes:
>In article <662@mks.UUCP>, wheels@mks.UUCP (Gerry Wheeler) writes:
>> If I may, I'd like to make a request of you software authors out there
>> -- please write your programs so they will handle either type of slash
>> in pathnames.  It would make life easier for many people. 
>
>It would indeed.  Most of the MS-DOS utilities will accept either one,
>but "subst" will not, and both MSC and Borland's linker demand backslashes.
>A recent conversation about Borland's new debugger, which also demands
>
>"Well, OS2 doesn't allow it, so get used to backslashes."

I have to whole heartedly agree with Gerry on this one.  I would like
to ask all software authors, commercial and public domain, please make
sure your programs can handle either the forward slash or back slash
character as the separator.

You know it is sooOOOoooo easy to do, there is no reason that I can
understand not to.  Some people might say, "It is an undocumented
feature so I won't use it!"  Yet so much DOS software *must* use
other undocumented stuff I can't see why *this* feature is singled
out for avoidance.  I have seen some programs published by PC Mag
which uses every trick (not) in the book for TSRs but don't handle
the '/' as a path separator.

And it is very easy to do, as I said before.  All a program has to do
is find out the current setting of the switch char.  This is a trivial
task for a program.  In fact, in Turbo C v2.0, in the file getopt.c
supplied by Borland, there is the 3 lines necessary to get the current
switch char.  Then, if the current switch char is '-', then
assume the path separator is the '/';  if the switch char is not the
'-', then I would say it is safe that you can assume the path separator
is the '\'.  When I ported the BSD indent(1) program to DOS, I had to
modify the code to handle creating backup file names.  Enclosed below
is the code segment for how I handled it:
/*
 * copy input file to backup file.
 *
 * The strategy for handling appending a suffix has been modified
 * from the original for use on MS-DOS.
 *
 * If there is no suffix on the input file name then the suffix
 * ".BAK" will simply be concatenated.  If there is a suffix,
 * then it will be stripped before the ".BAK" is concatenated.
 *
 * However, for MS-DOS, we must check to see what the *probable*
 * path separator character is by looking at the value of the current
 * command line switch character.  If the 'switchar' is a '-' as in UNIX,
 * then we will assume the path separator is a '/'.  If the 'switchar'
 * is not '-', then we assume it is a '/', the MS-DOS standard, and
 * assume the path separator character is the MS-DOS standard '\'.
 *
 * Then make the backup file the input and original input file the output. 
 */
bakcopy()
{
	int             n, bakchn;
	char            buff[BUFSIZ];
	register char  *p;
	char           *rindex();
	char path_separator;		/* depends on current DOS switchar */
	char suffix[4];			/* buffer for any filename suffix */
	char *strsuffix(char *, char *); /* get string suffix */

	/* first, construct the backup filename */
	path_separator = (getswitchar() == '-') ? '/' : '\\';
	if ((p = rindex(in_name, path_separator)) != NULL)
		p++;
	else
		p = in_name;
	(void)strcpy(bakfile, p);
	if (strsuffix(bakfile, suffix) != '\0') {
		p = rindex(bakfile, '.');
		*p = '\0';
	}
	(void)strcat(bakfile, ".BAK");

Again, I urge all software writers to add this very easy, nice to the
user feature to their programs.  It would sure make going between
UNIX and DOS much more pleasant.

George B. Smith
Stratus Computer, Inc
gbs@stratus.stratus.com
{amdahl,oliveb,uunet}!stratus!gbs

alex@mks.UUCP (Alex White) (02/12/89)

In article <1623@stratus.UUCP>, gbs@stratus.UUCP (George B. Smith) writes:
> In article <10353@ut-emx.UUCP> nather@ut-emx.UUCP (Ed Nather) writes:
> >
> >It would indeed.  Most of the MS-DOS utilities will accept either one,
> >but "subst" will not, and both MSC and Borland's linker demand backslashes.
> >A recent conversation about Borland's new debugger, which also demands
> >
> >"Well, OS2 doesn't allow it, so get used to backslashes."
Interestingly enough, MSC's interface ``cl'' accepts either - or /
for options.
It is also explicitly documented in their manuals, that / may be used
in #include filenames so that you can exchange programs with Xenix.
OS/2 has just made things worse - cmd.exe now takes `^' (the uparrow, cap)
as an escape character, doing what `\' has always done under unix.
OS/2 and DOS all continue to accept either slash in all system calls
interfacing to the kernel.

vg55611@ihuxy.ATT.COM (Gopal) (02/12/89)

In article <1623@stratus.UUCP> gbs@stratus.UUCP (George B. Smith) writes:

[stuff deleted]

>I have to whole heartedly agree with Gerry on this one.  I would like
>to ask all software authors, commercial and public domain, please make
>sure your programs can handle either the forward slash or back slash
>character as the separator.

[stuff deleted]

!And it is very easy to do, as I said before.  All a program has to do
!is find out the current setting of the switch char.  This is a trivial
!task for a program.  In fact, in Turbo C v2.0, in the file getopt.c
!supplied by Borland, there is the 3 lines necessary to get the current
!switch char.  Then, if the current switch char is '-', then

[stuff deleted]

There is an even simpler method: allow only "-" to be used as the
switchar in your programs, and then whenever you read a pathname from
the  user, substitute all occurences of "/" with "\".

Venu P. Gopal
UUCP:	att!ihuxy!vg55611
Internet: vg55611@ihuxy.att.com
BITNET: com%"vg55611@ihuxy.att.com"   or   com%"vg55611%ihuxy@research.att.com"

yogi@humus.Huji.AC.IL (Yossi Gil) (02/12/89)

According to the last rumor I heard, DOS (>= 3.0) system calls,
or int 21 functions in the PC slang, treat equally the '/'
and the '\'. The one to blame for the backslash backward
thinking is command.com. Anyone knows more about it?

hollen@spot.megatek.uucp (Dion Hollenbeck) (02/13/89)

From article <8769@orstcs.CS.ORST.EDU>, by sagen@nucthy.physics.orst.edu (Milt Sagen):
> 
> Making the backslash character the directory separator was a stupid idea.  
> Consider the fact that the backslash character is not located at any one place
> between keyboards.  It is such a pain to go to a different machine with a 
> different keyboard with a different location for the backslash yet running the
> same operating system.
> 
In addition to that it is schizophrenic for us UNIX users when switching
back and forth between DOS and UNIX.  Even more frustrating is using the
MKS Toolkit on DOS - now two different pieces of the same computer use
different switch characters!

	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

                                seismo!s3sun!megatek!hollen
                                ames!scubed/

alanf%smile@Sun.COM (Alan Fargusson @ peace with the world) (02/14/89)

There is a small miss-conception here.  MS-DOS allows both forward
and backward slants in path names.  It is command.com that takes
the forward slant, so you cannot use it unless you change the switchchar.
Programs should be coded to allow both.  It is actually valid to combine
both in one path name.

A little history: command.com is designed to look like the CP/M command
interpreter which uses the forward slant as a switchchar.  Remember that
MS-DOS 1.X did not have a hierarchal file system, so there was no conflict.
- - - - - - - - - - - - - - - - - - - - -
Alan Fargusson		Sun Microsystems
alanf@sun.com		..!sun!alanf

tmurphy@wpi.wpi.edu (Tom [Chris] Murphy) (02/14/89)

I once forgot where I was and used a / instead of a \ in a config.sys
file under 3.2.  The dammed thing worked!  Until I went to 3.3 ....


-- 
Thomas C. Murphy         Worcester Polytechnic Institute CAD Lab
Internet:   tmurphy@zaphod.wpi.edu   tmurphy@wpi.wpi.edu
BITNET:     TMURPHY@WPI
CompuServe: 73766,130

pt@geovision.uucp (Paul Tomblin) (02/15/89)

In article <1623@stratus.UUCP> gbs@stratus.UUCP (George B. Smith) writes:
>>In article <662@mks.UUCP>, wheels@mks.UUCP (Gerry Wheeler) writes:
>>> If I may, I'd like to make a request of you software authors out there
>>> -- please write your programs so they will handle either type of slash
>>> in pathnames.  It would make life easier for many people. 
>
>I have to whole heartedly agree with Gerry on this one.  I would like
>to ask all software authors, commercial and public domain, please make
>sure your programs can handle either the forward slash or back slash
>character as the separator.
I don't know if it is true of 2.0, but turboC 1.5 handled either syntax
no matter what your switchar was.  I was typing in the following to
TurboC for a few days before I realized that I had been lucky that it had
worked:
	tcc -I/gvc/includes -I/turboc/includes  dba.c
or even
	tcc -I/gvc/includes -I\turboc\includes c:/csource/dba.c

Holey metacharacters, batman.

I had tried a simple switchar program for a while, thinking it would
ease my daily transition between DOS and Unix, but found that MOST
commercial programs I tried, and most dos utils, don't understand it.
Sigh...

>...When I ported the BSD indent(1) program to DOS...
Did you do this?  CAN I HAVE IT?!

Thanks...

-- 
Paul Tomblin,  Second Officer, Golgafrinchan B Ark      | Canada's Acid Lakes:
    UUCP:   nrcaer!cognos!geovision!pt ??               | 150,000 Points of 
    Disclaimer: The opinions expressed here aren't      | Blight.
    necessarily even mine!                              | 

allbery@ncoast.ORG (Brandon S. Allbery) (02/16/89)

As quoted from <10353@ut-emx.UUCP> by nather@ut-emx.UUCP (Ed Nather):
+---------------
| "Well, OS2 doesn't allow it, so get used to backslashes."
+---------------

Who uses OS/2?

I dunno about anyone else, but I'm considering porting a simple database
manager or clone thereof (say, a clone of Informix 3.30 [pre-SQL]) to Minix
and suggesting *that* as an alternative to OS/2.  It doesn't even need a 4MB
286 box to run!

++Brandon
-- 
Brandon S. Allbery, moderator of comp.sources.misc	     allbery@ncoast.org
uunet!hal.cwru.edu!ncoast!allbery		    ncoast!allbery@hal.cwru.edu
      Send comp.sources.misc submissions to comp-sources-misc@<backbone>
NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser

zu@ethz.UUCP (Urs Zurbuchen) (02/16/89)

In article <1623@stratus.UUCP> gbs@stratus.UUCP (George B. Smith) writes:
>I have to whole heartedly agree with Gerry on this one.  I would like
>to ask all software authors, commercial and public domain, please make
>sure your programs can handle either the forward slash or back slash
>character as the separator.
Is there really anyone disagreeing? Life could be much more easier if it
was done this way.

>And it is very easy to do, as I said before.  All a program has to do
>is find out the current setting of the switch char.
Now, I don't agree with this one. Why not allow '/' and '\' as directory
separators in pathnames. In most cases you even don't have to stick
with '-' as the switch character but can allow '/' as that, too.

>...  Then, if the current switch char is '-', then
>assume the path separator is the '/';  if the switch char is not the
>'-', then I would say it is safe that you can assume the path separator
>is the '\'.
The safest way is to test for '/' as the switch character. If so, path
separator has to be '\'. Otherwise it's '/'. No need to test for '-'.

		Have a nice day,
		      ...urs

UUCP: ...!mcvax!cernvax!ethz!zu

gbs@stratus.UUCP (George B. Smith) (02/20/89)

In article <783@ethz.UUCP> zu@bernina.UUCP (Urs Zurbuchen) writes:
>In article <1623@stratus.UUCP> gbs@stratus.UUCP (George B. Smith) writes:
>>And it is very easy to do, as I said before.  All a program has to do
>>is find out the current setting of the switch char.
>Now, I don't agree with this one. Why not allow '/' and '\' as directory
>separators in pathnames. In most cases you even don't have to stick
>with '-' as the switch character but can allow '/' as that, too.

I would answer that I think it is ugly to have *both* backslashes *and*
forward slashes in the same path name.  I would say that at some level
this can be considered a personal, esthetic consideration and would be
very hard to agree on.  I just prefer C:/top/sub1/sub2/file over
C:\top/sub1\sub2/file.  Although, on a technical level, mixing the
separator characters would effectively disallow the use of the backslash
as an escape character which is a common convention.  I would hazard the
guess that people who would like to use the forward slash as the path
separator would like to use the backslash as the escape character.

>>... if the current switch char is '-', then
>>assume the path separator is the '/';  if the switch char is not the
>>'-', then I would say it is safe that you can assume the path separator
>>is the '\'.
>The safest way is to test for '/' as the switch character. If so, path
>separator has to be '\'. Otherwise it's '/'. No need to test for '-'.

I agree with Urs on this point.  I will change my code to do as
he suggests.  Thanks for the insight.

>		Have a nice day,
>		      ...urs

And to you.
George B. Smith
Stratus Computer, Inc
gbs@stratus.stratus.com
{amdahl,oliveb,uunet}!stratus!gbs