zipping a file by command line

I come across a very strange behavior here with Xojo. I have inserted comments in the relevant places! Replace the code in PushButton1.Action in my project from above with the following:

[code]#If TargetMacOS Or TargetLinux

Dim dialog As New SaveAsDialog
Dim output As FolderItem = dialog.ShowModalWithin(Self)

If output <> Nil Then

TempFolder = SpecialFolder.Desktop.Child("foo")
TempFolder.CreateAsFolder

CreateTempFolder(TempFolder)

Dim command, inputPath, outputPath As String

inputPath = """" + TempFolder.NativePath + """"
outputPath = """" + output.NativePath + """"

' This doesn't work correctly. The extra folder "Users/..." will be included.
' command = "cd " + inputPath + "; zip -r -q " + outputPath + " " + inputPath + " *"

' This works correctly, but with a weird command string.
' You can also see it on the Xojo Syntax highlightning.
command = "cd """ + TempFolder.NativePath + """; zip -r -q """ +_ 
  output.NativePath + """ "" + TempFolder.NativePath + "" *"

Shell1.Execute(command)

End If

#EndIf[/code]

Are-you sure about the number of quotes ?

inputPath = """" + TempFolder.NativePath + """" outputPath = """" + output.NativePath + """"

4 quotes means 2 quotes (an empty string.

Later, 3 quotes + 1 space + 2 quotes ???

This does not makes sense to me.

Of course, I may be wrong.

@Emile Schwarz Did you tried my code? If you wanna add quotes into a string, you need to uses a double quote to get one quote.
I modified the command string and now it works fine:

command = "cd " + inputPath + "; zip -r -q " + outputPath + " *"

[quote=432888:@Martin Trippensee]@Emile Schwarz Did you tried my code? If you wanna add quotes into a string, you need to uses a double quote to get one quote.
I modified the command string and now it works fine:

command = "cd " + inputPath + "; zip -r -q " + outputPath + " *"

I just got back to my desk and was going to send that. Good discovery.

Yes, I know, but four quotes ?

@Emile Schwarz — It’s weird, I know:

  1. The first quote opens the string
  2. The 2 quotes inside mean one quote only (i.e. Chr(34))
  3. The last quote ends the string literal

:frowning:

You could also use ChrB(34), but most of us find the “” mechanism more legible (once we know how it works).