用 PC-DCL 替代 cmd

在 Windows 上用 VMS DCL 作为日常使用的 shell。 我把开源的 PC-DCL 改了下,能用 MSVC 编译成 64 位应用了(把 Unix 支持丢了),井制作了 Installer

LdBeth/PC-DCL: PC-DCL is an emulation of the DCL command language interpreter

Comparison of PC-DCL vs. Open DCL Lite

PC-DCL Version 4.07D 27-Oct-2024
running on Professional  (Build 9200)

Type LOgout to quit...

D:[Program Files (x86).PCDCL]_$ dir

Directory D:[Program Files (x86).PCDCL]

[Examples]     [Help]         changes.txt    dcl.exe        dcl.ini        dcl2.exe       DEBUG.LOG      license.txt

login.dcl      logout.dcl     pcre.dll       uninst.exe
Total of 12 files
D:[Program Files (x86).PCDCL]_$ ty log*.dcl

login.dcl

$!       set verify
$       w :== WRITE SYS$OUTPUT
$       if f$mode() .eqs. "INTERACTIVE"
$!              dir :== dir /size /date
$               del :== del /log
$               set term /insert /clear
$               set prompt $p_"$ "
$               show version
$               w "Type LOgout to quit..."
$               w " "
$               tst :== "set def sys$dcl:[examples]"
$       endif
$       define SYS$ERROR SYS$OUTPUT
$       define /key/nolog/erase/terminate f10 "recall /all"
$       define /key/nolog/erase f11 "recall "
$       define /key/nolog/erase/term/noecho f12 cls
$       define /key/nolog/erase/term/noecho sf12 step

logout.dcl

$       if f$mode() .EQS. "INTERACTIVE"
$               w "bye bye "+F$USER()
$       endif
D:[Program Files (x86).PCDCL]_$
D:[Program Files (x86).PCDCL]_$ sho log
"INI$USERNAME" = "ldb"
"INI$EXT" = "dcl"
"INI$FTYPE" = "VMS"
"INI$DOS" = "YES"
"INI$STRICT" = "NO"
"INI$SWITCHAR" = "/"
"SYS$INPUT" = "SYS$INPUT"
"SYS$OUTPUT" = "SYS$OUTPUT"
"SYS$DISK" = "D:"
"SYS$LOGIN_DEVICE" = "D:"
"SYS$LOGIN" = "C:[Users.ldb]"
"SYS$SCRATCH" = "C:[Users.ldb]"
"SYS$DCL" = "D:[Program Files (x86).PCDCL]"
"SYS$HELPDIR" = "D:[Program Files (x86).PCDCL.help]"
"SYS$ERROR" = "SYS$OUTPUT"
D:[Program Files (x86).PCDCL]_$ sh cp

CPU 0
Identifier = Intel64 Family 6 Model 167 Stepping 1
ProcessorNameString = 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
VendorIdentifier = GenuineIntel
FeatureSet = 823869439  (0x311B3FFF)
~MHz = 3504  (0xDB0)
...

不用再处理CMD的文本编码问题了吗

在 Windows 上是通过 system()popen() POSIX 调用执行命令,本质还是在调用 CMD,这样就不用重造轮子来处理环境变量替換和输入输出重定向,但是会尊重 POSIX locale 的设定,可以通过 setlocale() 影响编码。既然是开源的,加点代码改下就行,不过 PC DCL 就没支持处理 wide character,我也没这需求,涉及多语言的处理都用 Emacs 做的。