News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

problem with assembling with '&' in foldername

Started by Rainstorm, March 02, 2008, 02:06:40 AM

Previous topic - Next topic

Rainstorm

Hi

while assembling i've found that there's some problem if i have the character '&' in my foldername
why does that happen ?
the version am using is 9 though

It says can't find the file or something & the filename mentioned seems to be the part of the Foldername before the '&'

thx

zooba

The "&" character is a special character within the command line. It appears to be used to separate multiple commands on a single line. For example:

C:\>choice & echo Hello
[Y,N]?Y
Hello

C:\>


Compare and contrast with && and ||, which execute the next command only if the previous one was unsucessful or sucessful, respectively.

To solve your problem, you will need to put "quotation marks" around your filename.

Cheers,

Zooba :U

Rainstorm

hey zooba,
am using the masm batch files which come along with the package, & they seem to have quotation marks around the "%1"

thankyou

zooba

I don't have those batch files so I can't look myself, but I'd guess there's (at least) one case somewhere that isn't quoted.

Do your batch files work if you have spaces in the path but not ampersands?

Rainstorm

zooba wrote..
QuoteDo your batch files work if you have spaces in the path but not ampersands?
no they don't,.. same effect

I've attatched the masm32 .bat file for 'Assemble & link' which i use. (build.bat)
just change the extension after you dload
t  y

[attachment deleted by admin]

MichaelW

The file build.bat differs from the other batch files in that on the link command lines there are quotes around the %1.obj, but removing them does not correct the problem. "C:\masm32\My\_TRY\test" works correctly for all of the batch files, but "C:\masm32\My\bad&dir\test" fails for build.bat. I'm not sure what is causing the problem, but the solution is obvious :bg
eschew obfuscation

Rainstorm

lol what?.... don't use '&'s ?   : )
with spaces too it doesn't work.

t h x

MichaelW

For me it fails whether I use "bad dir" or "bad&dir", but there is a difference in the way that it fails. With a space ML reports that it cannot find the file. With & the:

if exist "%1.obj" del "%1.obj"

statement fails and the batch file dies. If I comment out that statement then the:

if exist "%1.exe" del "%1.exe"

statement fails and the batch file dies. If I comment out both statements, then ML reports that it cannot find the file. So the solution is to avoid paths that contain either character.

eschew obfuscation

zooba

The problem appears to be multiple sets of quotation marks. The parameter passed to the batch file needs to be in quotation marks to keep it all as one argument. If it is then used within quotation marks it will not work.

rem TEST.BAT

if exist "%1.obj" del "%1.obj"


C:\TEST.BAT "bad dir"

Executes:
if exist ""bad dir".obj" del ""bad dir".obj"

The batch files should avoid quoting parameters and they should be quoted when calling. If you need a different extension it's easiest to pass it as a parameter (QEditor's menu system will allow this):

C:\TEST.BAT "file with a space.asm" "file with a space.obj"

I'm sure it's possible to detect and remove extra quotation marks in a batch file, but I'm not keen to figure it out.

The reason for the different error messages is that a space separates arguments while an ampersand separates commands - the command interpreter doesn't validate arguments.

Cheers,

Zooba :U

MichaelW

Yes, the batch file build.bat, or at least the one that I have, contains quotes that are not in the other batch files.

build.bat:

if exist "%1.obj" del "%1.obj"
if exist "%1.exe" del "%1.exe"
\masm32\bin\ml /c /coff "%1.asm"
dir "%1.*"

others:

if exist %1.obj del %1.obj
if exist %1.exe del %1.exe
\masm32\bin\ml /c /coff %1.asm
dir %1.*

And eliminating the quotes from build.bat allows it to work with both of my bad paths.

eschew obfuscation