[comp.os.msdos.misc] switchar anyone?

mrd@ecs.soton.ac.uk (Mark Dobie) (08/13/90)

OK, so I discovered switchar and I have set it to '-' to make my PC
look more like UNIX. This is PC-DOS 3.3.

I have found a few problems and have a few questions.

Is switchar still supported in the latest MSDOS/PCDOS?

Although I can use '-' for options and '/' for pathnames, this
doesn't work all the time.

For instance, I can say 'dir /bin/foo' or 'dir \bin\foo' or even
'dir \bin/foo', but if I try to execute it, ie '/bin/foo' I get an
EXEC error. Is this a problem with command.com?

Also, if I start another command.com (within the one I set the switchar
in), the prompt shows up with forward slashes (UNIX style). ANy idea
how I can make the top level command.com do this?

And, of course, many programs don't bother checking it. Even PCDOS
utilities like xcopy and tree. If only people like Microsoft and
Borland provided a getopt function for option argument processing,
then it could do the checking.

Thanks a lot

-- 

Mark Dobie                              M.Dobie@uk.ac.soton.ecs (JANET)
University of Southampton		M.Dobie@ecs.soton.ac.uk (Bitnet)

hp@vmars.tuwien.ac.at (Peter Holzer) (08/30/90)

mrd@ecs.soton.ac.uk (Mark Dobie) writes:

>Is switchar still supported in the latest MSDOS/PCDOS?

I have heard they have abandoned it in DOS 4.0 (I don't have 4.0, so I
cannot check this). It does not work in OS/2's DOS-box (But who uses OS/2
anyway :-)

>And, of course, many programs don't bother checking it. Even PCDOS
>utilities like xcopy and tree. If only people like Microsoft and
>Borland provided a getopt function for option argument processing,
>then it could do the checking.

Borland does! On the distribution disks of Turbo-C 2.0 is a file 
getopt.c, which does use the switchar (It was there all the time since 1.0, 
if I remember correctly). 

--
|    _	| Peter J. Holzer			| Think of it	|
| |_|_)	| Technische Universitaet Wien		| as evolution	|
| | |	| hp@vmars.tuwien.ac.at			| in action!	|
| __/  	| ...!uunet!mcsun!tuvie!vmars!hp	|     Tony Rand	|

ho@hoss.unl.edu (Tiny Bubbles...) (08/30/90)

In <3388@ecs.soton.ac.uk> mrd@ecs.soton.ac.uk (Mark Dobie) writes:

>For instance, I can say 'dir /bin/foo' or 'dir \bin\foo' or even
>'dir \bin/foo', but if I try to execute it, ie '/bin/foo' I get an
>EXEC error. Is this a problem with command.com?
>Also, if I start another command.com (within the one I set the switchar
>in), the prompt shows up with forward slashes (UNIX style). ANy idea
>how I can make the top level command.com do this?

The switchar() call is not supported in DOS 3.x, I don't think.  It's still
there as a DOS call, but IBM and Microsoft "expect" you not to use it.

The top-level COMMAND.COM, after discovering that it is in fact top-level,
makes the call to set switchar to '/' -- and then ASSUMES that it will 
remain this way, without further checking.  That's why second-level COMMAND
will get the forward slash at the prompt, but the top-level won't.

You can't make the top-level command start its prompt with a slash unless 
you reach into COMMAND and patch the call.  (It's pretty simple -- just
search for the MOV AH, ## -- whatever the call is, I forget -- and the 
INT call.)

Also, if you have a complicated directory tree (like, more than one level
off of root), you will NEVER get the prompts to look right.  That's because
the internal directory tables in DOS always use '\' as the separator
before subdirectories, regardless of subdirectory.

So you get nonsensical prompts like "C:/EAT\MY\SHORTS>" and, if you're not
careful, programs can be tripped up very easily by this -- either that you
write or that other vendors have written.

I haven't tried anything like that lately, so I can't say for sure.
--
---
        ... Michael Ho, University of Nebraska
Internet: ho@hoss.unl.edu

harper@convex.com (David Harper) (08/31/90)

In article <3388@ecs.soton.ac.uk> mrd@ecs.soton.ac.uk (Mark Dobie) writes:
>OK, so I discovered switchar and I have set it to '-' to make my PC
>look more like UNIX. This is PC-DOS 3.3.
>
>I have found a few problems and have a few questions.
>
>Is switchar still supported in the latest MSDOS/PCDOS?
>
>Although I can use '-' for options and '/' for pathnames, this
>doesn't work all the time.

Unfortunately, there are a bunch of programs out there which have checks for
'\' and '/' hard coded into them.  Setting the switchar won't work with these
programs.  A far better way is a TSR which interperts the command line before
it is passed to the application (or command.com).  This TSR would automatically
translate '/' to '\' and '-' to '/' so that the application would see what it
was expecting.  Fortunately, such a TSR exists; it is called ANARKEY (by 
Stephen Calwas) and can be found on most BBSs, as well as, many internet
archive sites such as simtel.  In addition, this program gives a host of other
nice features such as command line editing, history functions, command/file
name completion, etc.  It is worth every penny of the shareware registration
costs.


Dave Harper    -     Convex Computer Corp.            E-mail address:
3000 Waterview Pky.  Richardson, TX 75081             harper@convex.COM
(214) 497-4525 (W)   (214) 727-4206 (H)

andy@mks.com (Andy Toy) (09/04/90)

In article <105625@convex.convex.com> harper@convex.com (David Harper) writes:
>Unfortunately, there are a bunch of programs out there which have checks for
>'\' and '/' hard coded into them.  Setting the switchar won't work with these
>programs.  A far better way is a TSR which interperts the command line before
>it is passed to the application (or command.com).  This TSR would automatically
>translate '/' to '\' and '-' to '/' so that the application would see what it
>was expecting.  

This will work most of the time, but there are some cases where this
will not work.  DOS allows both slashes for path delimiters.  Lots of
programmes already accept both `/' and `\' for the path delimiter and
always use `-' for the switch character.  Changing `-' to `/' is not
correct for programmes that always use `-' for options.  Then there are
those obscure programmes that use *BOTH* `-' and `/' for options.
-- 
Andy Toy, Mortice Kern Systems Inc.,       Internet: andy@mks.com
  35 King Street North, Waterloo,       UUCP: uunet!watmath!mks!andy
      Ontario, CANADA N2J 2W9      Phone: 519-884-2251  FAX: 519-884-8861

steveha@microsoft.UUCP (Steve Hastings) (09/08/90)

In article <1990Sep4.165921.6697@mks.com> andy@mks.com (Andy Toy) writes:
>In article <105625@convex.convex.com> harper@convex.com (David Harper) writes:
>>A far better way is a TSR which [ ... ] would automatically
>>translate '/' to '\' and '-' to '/'
>
>This will work most of the time, but there are some cases where this
>will not work.

The shell in the _Thompson Toolkit_ (formerly known as _PolyShell_) has a
feature which can do the translation on a command-by-command basis.  If you
type

fixbs command arguments

the shell will fix up the command line before passing it to DOS for
execution.  (Naturally I use shell aliases to avoid typing "fixbs" all the
time.)  This does not help *inside* an application, of course, but it
allows you complete control over which applications get the translation and
which don't.
-- 
Steve "I don't speak for Microsoft" Hastings    ===^=== :::::
uunet!microsoft!steveha  steveha@microsoft.uucp    ` \\==|

ts@uwasa.fi (Timo Salmi LASK) (09/08/90)

In article <3388@ecs.soton.ac.uk> mrd@ecs.soton.ac.uk (Mark Dobie) writes:
>OK, so I discovered switchar and I have set it to '-' to make my PC
>look more like UNIX. This is PC-DOS 3.3.
>I have found a few problems and have a few questions.

There is an alternative switchar utility in the /pc/ts/tsutld17.arc
collection, which you might try out.  Available by anonymous ftp
from chyde.uwasa.fi, Vaasa, Finland.  But as many posters have
pointed out, switchar facilities are not unproblematic. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun