On Mon, Dec 5, 2016 at 4:49 PM, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > > You've never used cmd.com or command.exe? "The DOS prompt"?
The default Windows shell is "cmd.exe", and it's informally called the "Command Prompt", not "DOS Prompt". In Windows 9x it was accurate to say DOS prompt, since the shell was COMMAND.COM, which used DOS system calls. But that branch of Windows has been dead for over a decade. > Even the DOS prompt supports some level of globbing. Its been a while since > I've used the DOS prompt in anger, but I seem to recall being able to do > things like: > > dir a* "dir" is a built-in command. It calls FindFirstFileExW to list each directory that it walks over. FindFirstFileExW converts the glob to a form supported by the system call NtQueryDirectoryFile. In this case that's simply "a*". In other cases it tries to match the behavior of MS-DOS globbing, which requires rewriting the pattern to use DOS_STAR ('<'), DOS_QM ('>'), and DOS_DOT ('"'). To simplify the implementation, the five wildcard characters are reserved. They're not allowed in filenames. The I/O manager leaves the implementation up to the filesystem driver. NtQueryDirectoryFile gets dispatched to the driver as an I/O request packet with major function IRP_MJ_DIRECTORY_CONTROL and minor function IRP_MN_QUERY_DIRECTORY. The driver does most of the work, including filtering the directory listing by the FileName argument. But a driver writer doesn't have to reinvent the wheel here; the filesystem runtime library has string comparison functions that support wildcards, such as FsRtlIsNameInExpression. > *every single command and application* has to re-implement its own globbing, > very possibly inconsistently. C/C++ programs can link with wsetargv.obj to support command-line globbing. For Python, this dependency can be added in PCBuild/python.vcxproj in the linker configuration: <Link> <SubSystem>Console</SubSystem> <StackReserveSize>2000000</StackReserveSize> <BaseAddress>0x1d000000</BaseAddress> <AdditionalDependencies>wsetargv.obj</AdditionalDependencies> </Link> For example: C:\Temp\test>dir /b a.txt b.dat c.bin C:\Temp\test>python -c "import sys;print(sys.argv)" *.txt *.dat ['-c', 'a.txt', 'b.dat'] -- https://mail.python.org/mailman/listinfo/python-list