Filenames with leading minus symbol issue

Started by Vortex, April 15, 2025, 09:39:39 PM

Previous topic - Next topic

Vortex

Hello,

Poasm,Polink and Porc does not accept a leading - symbol in the filenames :

C:\PellesC\bin\poasm.exe /AIA32 "-sample.asm"
POASM: warning: Unrecognized option '/sample.asm'.
Pelles Macro Assembler, Version 13.00.11

C:\PellesC\bin\polink.exe /SUBSYSTEM:CONSOLE "-sample.obj" msvcrt.lib
POLINK: warning: Unrecognized option '/sample.obj'; ignored.
POLINK: fatal error: No output file specified.

Reported by Polink Version 13.00.0

\PellesC\bin\porc.exe "-sample.rc"
PORC: fatal error: Unrecognized option /sample.rc.

Reported by Porc Version 13.00.0
Code it... That's all...

Pelle

This is really by design. Both /option and -option is allowed, and supporting -filename would require much more code for a basically non-existing case.
/Pelle

Stefan Pendl

How about introducing the "--" switch that signals the end of the parameters?
Many Unix utilities support this.
---
Stefan

Proud member of the UltraDefrag Development Team

TimoVJL

#3
That issue was about checking douple quote in commandline parser for future use.
A silly filename case with switch char as first char in filename.

So solution is simple: don't ever use that char as first char in filename

>cl.exe -c "-test.c"
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '-test.c'
cl : Command line error D8003 : missing source filename
May the source be with you

Vortex

Hi Pelle,

Thanks for the explanation, it's OK. No any leading - symbol to name files.
Code it... That's all...

Pelle

Quote from: Stefan Pendl on April 17, 2025, 07:28:16 AMHow about introducing the "--" switch that signals the end of the parameters?
Many Unix utilities support this.
Not many Windows command-line tools, though (AFAIK).
/Pelle

Pelle

All/most PO*.EXE command-line tools use functions from the same helper library.

One function in this library splits the string from Windows into an "argv" array. This function will handle quotes in the string from Windows, to support filenames with spaces, but any quotes are dropped before the name is placed in the "argv" array (to simplify further processing). Once the "argv" array is constructed, names beginning with "/" or "-" are considered options (names beginning with "@" may get other treatment, etc.)

Other solutions are obviously possible, but "-filename" seems like a silly non-issue to begin with...
/Pelle