Change \ to / in DOS

22 views
Skip to first unread message

Michael J. Vincent

unread,
Oct 22, 2001, 2:29:46 PM10/22/01
to
I came upon a piece of freeware code which enabled swapping the "\"
directory symbol in DOS to "/" which would emulate UNIX like directory
symbols. It had something to do with changing the escape character for
command line switches from the "/" to the "-". Does this sound familiar to
anyone?

Unfortunately, I didn't grab that software (kicking myself now). Does
anyone know if this can be done and if so, how?

cheers.

m...@here.com

unread,
Oct 22, 2001, 3:30:52 PM10/22/01
to
The \ to / conversion was actually part of some older (2.11?
3.0? 3.1?) DOS, so that freeware utility (if it was from that
time) didn't have to do a whole lot. I think the hooks for
switchar are no longer in DOS.

Timo Salmi

unread,
Oct 22, 2001, 4:13:27 PM10/22/01
to
Michael J. Vincent <mjvi...@lucent.com> wrote:
> I came upon a piece of freeware code which enabled swapping the "\"
> directory symbol in DOS to "/" which would emulate UNIX like directory

> Unfortunately, I didn't grab that software (kicking myself now). Does

> anyone know if this can be done and if so, how?

Frankly, don't use it, or use it at your own peril, but anyway:

ftp://garbo.uwasa.fi/pc/ts/tsutld25.zip Fourth set of Utilities, T.Salmi
Filename Comment Date Time
-------- -------------------------------- ---- ----
ADJCURS.BAT Batch shell for adjusting cursor 01-11-00 22:58:30
BIGCURS.EXE Make the cursor better visible 09-13-92 07:46:58
BIGNCURS.EXE NonResident temporary big cursor 01-11-00 23:03:54
CAPS.EXE Get/set keyboard toggles 01-11-00 23:04:12
FILES.EXE Summary of your different files 01-11-00 23:06:32
FILE_ID.DIZ Brief characterization of tsutld 01-11-00 22:44:06
KEYRATE.EXE Set keyboard repeat rate & delay 01-11-00 23:07:24
POPSCR.EXE Pop screen from image file 01-10-00 09:51:30
PSK.EXE Dis/enable the PrintScreen key 01-25-97 23:04:42
PUSHSCR.EXE Push screen to image file 01-10-00 09:50:50
SETPRT.EXE Set PrintScreen retry times 01-11-00 23:10:24
SWITCHAR.EXE Makes Unix freaks feel at home 01-11-00 23:11:52 <---
TODAY.EXE Scan disk for files made today 07-27-00 20:15:58
TSPROG.INF List of programs from Timo Salmi 03-26-00 18:03:18
TSUTLD.INF Document 08-01-00 10:01:30
TSUTLD.NWS News announcements about tsutld 08-01-00 09:59:54
VAASA.INF Info: Finland, Vaasa, U of Vaasa 10-18-97 13:18:46
WARMBOOT.EXE Reboot with/without memory tests 01-11-00 23:12:50
---- ------ ------ -----
0018 175598

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

Yngvar Folling

unread,
Oct 25, 2001, 11:13:44 AM10/25/01
to
In article <9r1s5c$89i$2...@newshost.mot.com>, m...@here.com wrote:
> The \ to / conversion was actually part of some older (2.11?
> 3.0? 3.1?) DOS, so that freeware utility (if it was from that
> time) didn't have to do a whole lot. I think the hooks for
> switchar are no longer in DOS.

The function for *setting* the switch character is no longer in DOS
(eradicated some time during the 3.x versions, I think), but the
function for *getting* it may still be there for backwards compatibility
-- although without its counterpart it will obviously always return /.
I think they were both subfunctions of function INT 37H -- if only
because that number is a conspicuous hole in the list of documented DOS
functions.

In fact, since subdirectories were first included in DOS from version
2.0, the INT 21H functions have *always* accepted both \ and / as
subdirectory separators (hence the reason why neither of them are
allowed in names). The only reason that the command shell wouldn't
accept / in paths, is that all the commands interpreted it as lead-in to
a switch.

Thinking about it now, though, it occurs to me that - is a legal
character in file names, but this trick might cause trouble if we try to
use that.

I also remember that early versions of Borland/Turbo C/C++ included
getswitchar() and setswitchar() functions, but true to the undocumented
nature of the DOS functions they mapped to, Borland didn't document them
either. They stood there in plain sight in one of the header files,
though.

Anyway, as Timo said, this is of historical interest only. It is a very
bad idea to try to change the switch character nowadays.

Yngvar

Matthias Paul

unread,
Oct 25, 2001, 5:16:58 PM10/25/01
to
On 2001-10-22, Michael J. Vincent asked:

> I came upon a piece of freeware code which enabled swapping the "\"
> directory symbol in DOS to "/" which would emulate UNIX like directory
> symbols. It had something to do with changing the escape character for
> command line switches from the "/" to the "-". Does this sound familiar
> to anyone?

What you mean is the so called "SwitChar" API. You cannot directly
control the so called "path character" (´\´ under DOS and ´/´ under
Unix), but by controlling the SwitChar, you can indirectly influence
the use of the path character.

Here´s some info which replaces the partially faulty info in RBIL61
(will most probably have been corrected with RBIL62)...

------------------------------------------------------------
INT 21 - DOS 2+ - "SWITCHAR" - GET SWITCH CHARACTER
AX = 3700h
Return: AL = status
00h successful
DL = current switch character
FFh unsupported subfunction
Desc: Determine the character which is used to introduce command switches.
This setting is ignored by MS-DOS commands in version 4.0 and higher,
but is honored by many third-party programs and by Novell DOS 7
external commands
Notes: documented in some OEM versions of some releases of DOS
supported by OS/2 compatibility box
always returns AL=00h/DL=2Fh ('/') for MS-DOS 5+ and CCI Multiuser DOS
7.xx.
However, this function is fully supported by DR DOS 3.41 - 7.05,
including DR PalmDOS, Novell DOS, and OpenDOS, and also by
S/DOS 1.0+ and PTS-DOS 6.51+, all reporting the current SwitChar
as set by INT 21h/3701h. The default SwitChar is 2Fh ('/').
DR DOS 5.0+ COMMAND.COM (and NETWARE.COM) indicates switch
characters other than '/' by changing the first backslash (and only the
first one)
in the path it prints for CHDIR/CD and PROMPT $p with a forward slash.
DR-OpenDOS 7.02+ COMMAND.COM has a new pseudo environment variable
%/% added, representing the current SwitChar setting in batchjobs. Most
external
commands fully honor the SwitChar.
A future (post DR-DOS 7.03) COMMAND.COM will probably also provide
a new PROMPT $/ token and external commands should honor an
environment variable named %SWITCHAR%, overriding the SwitChar
setting returned from this function.
Because of all the implementation differences it is recommended
to preset DL = 2Fh when calling this function.
------------------------------------------------------------
INT 21 - DOS 2+ - "SWITCHAR" - SET SWITCH CHARACTER
AX = 3701h
DL = new switch character
Return: AL = status
00h successful
FFh unsupported subfunction
Notes: documented in some OEM versions of some releases of DOS; DOS 2.x had
a SWITCHAR=c setting in CONFIG.SYS
supported by OS/2 compatibility box and Novell DOS 7
ignored by MS-DOS 5+ and CCI Multiuser DOS 7.xx (and probably all
the other OS from the DR Multiuser DOS family)
Although DR DOS 6.0 (probably earlier???) - 7.05 leave AX unchanged,
this function is otherwise fully supported by DR DOS 3.41 - 7.05,
including DR PalmDOS, Novell DOS, and OpenDOS, and will actually
change the SwitChar setting. This holds true also for S/DOS 1.0+
and PTS-DOS 6.51+.
DR-OpenDOS 7.02 - DR-DOS 7.05 as well as S/DOS 1.0+ and PTS-DOS 6.51+
were enhanced to also support a SWITCHAR= directive in CONFIG.SYS
(accepting only '/' or '-').
------------------------------------------------------------

A few more notes:

FreeDOS also supports the SwitChar API and a CONFIG.SYS directive
SWITCHAR=c. JPSoft´s 4DOS command processor has a (sometimes
undocumented) SETDOS /Wc command to set the current SwitChar to c.
In the list displayed by SETDOS the current SwitChar occurs as
SWITCH=c (this, %/%, and the $p special case mentioned above can
be used to evaluate the SwitChar from within batchjobs without
3rd party tools - see MPDOSTIP.ZIP on my site for an example).

Since the API is not actually operational under MS-DOS/PC DOS you
will need a small (trivial) TSR which sits on top of this API and
allows to change the current setting. An example for such a TSR
can be found on Ralf Brown´s site as example for writing AMIS
conformat drivers, it´s called SWITCHAR.COM.

Regardless of the proper operation of, and the current SwitChar
setting as is, the DOS kernel itself will always accept ´/´ and
´\´ in filespecs!
However, many filespec crunching routines in applications and
libraries only sense for ´\´, so not all applications accept the
´/´ (in particular not in the command line where it might get
confused with the SwitChar if the code does not take this into
account).
Also, not all executables retrieve the current SwitChar setting
using this API (they really should - in all DOS issues up to the
present!), but work with hardwired ´/´ and/or ´-´ switch characters
instead and thereby make the API pretty much useless when you have
to use such executables.

Hence my suggestion to all DOS programmers: Please don´t forget
to support this really trivial API to retrieve the current SwitChar
setting in your applications and thereby make life easier for those
of us who have to switch between DOS and Unix. :-)

Matthias

--

Matthias Paul, Ubierstrasse 28, D-50321 Bruehl, Germany
<mailto:Matthi...@post.rwth-aachen.de>; <mailto:mp...@drdos.org>
http://www.uni-bonn.de/~uzs180/mpdokeng.html; http://mpaul.drdos.org

Stan Brown

unread,
Oct 28, 2001, 2:44:05 PM10/28/01
to
Michael J. Vincent <mjvi...@lucent.com> wrote in
comp.os.msdos.programmer:

It can't be done any more. Versions of COMMAND.COM over the past few
years no longer look at that flag when interpreting paths.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://oakroadsystems.com
My reply address is correct as is. The courtesy of providing a correct
reply address is more important to me than time spent deleting spam.

Reply all
Reply to author
Forward
0 new messages