Windows directory path

Por ro

Scribe (4383)

Imagen del ro

15-02-2021, 11:38

Hai, I enjoy the openMSX CLI especially on file transfer.
The diskmanipulator works for that. Sure. But, is there a setting or other that makes Windows slashes in Paths possible? I'm having troubles pasting file paths directly to the CLI.

So instead of drive:/path/file I'd like to use drive:\path\file Smile

Login sesión o register para postear comentarios

Por wouter_

Champion (456)

Imagen del wouter_

15-02-2021, 11:56

I'm afraid that's not possible Sad

The problem is that backslash is the escape-character. So in a character sequence like "path\file" the "\f" portion is seen as an "escaped f" (which is just a regular "f"). Obviously in this example escaping is useless. However it is useful in these examples:

    file\ with\ spaces
    "file with spaces and \"quotes\""

I suspect that something like drive:\\path\\file will work just fine (but not what you want).

These escaping rules are part of the Tcl language (and the openMSX CLI is a Tcl interpreter). So it's not something we have direct control over.

Por ro

Scribe (4383)

Imagen del ro

15-02-2021, 16:07

Hai Wouter,

I understand the underlying principles. whish we could just say set-dirseperator "\" -escape "`".. or something (*yes, that's me talking powershell notation)
and since MSXDOS2 uses the MS way.. well, the pain is obvious.

So, I have to make a powershell way of talking to openMSX then Smile As much as I like CLI, the openMSX take on CLI is not my fave so far.

So far you guys made a hell of a good emulator. hats of.
hulde!

Por turbor

Champion (475)

Imagen del turbor

15-02-2021, 19:25

Well as a long time *nix user I'm constantly baffled by the idea that you should use the escape characters as directory separator. All because MS-DOS thought they needed to be different then the other OS'es and use the '/' for CLI options instead of '-'. When they introduced subdirectories they needed an other character so they opted for the '\'... (and don't get me started about that drive letter thingy Sad )

If openMSX would allow \ as directory separator which character would you propose as escape character? I mean you would only be moving the problem around.

Por ro

Scribe (4383)

Imagen del ro

16-02-2021, 07:15

I hear you Smile But in the end, it's a matter of taste. I'm a big fan of "your workflow", what works for me doesn't have to for you and vice versa. So, use preferences to set up stuff the way you like it.

That could mean;
set directory_separator = "$"
set escape_character = "^"
set options_character ="]"

or
set directory_separator = "\"
set escape_character = "~"
set options_character ="/"

or
set directory_separator = "/"
set escape_character = "\"
set options_character ="-"

or whatever. make it possible to tune it Smile

Por pgimeno

Champion (288)

Imagen del pgimeno

16-02-2021, 21:46

Tcl has its requirements, but maybe a setting like: 'set escape_pastes = true' , that would catch the input string and escape it to Tcl-format it, might make sense.

For example, if you paste 'C:\name', if escape_pastes is true, that would be pasted as 'C:\\name', and if escape_pastes is false, it would be pasted as 'C:\name'.

Por turbor

Champion (475)

Imagen del turbor

17-02-2021, 15:39

there is this thing in TCL with braces...
Grouping words within double braces disables substitution within the braces. Characters within braces are passed to a command exactly as written. The only "Backslash Sequence" that is processed within braces is the backslash at the end of a line. This is still a line continuation character. So I came up with this little (untested) TCL code

proc fromdos {dosname} {regsub -all {\\} $dosnmae {/} }

This way you can type your drive:\path\file in between braces and the fromdos routine will translate this to the regular *nix like name. So if you have an ASCII basic program you could type it in in the emulated msx by running the following command in your openMSX console

type [read [open [fromdos {C:\direcroy\program.bas} ] ] ]

Por wouter_

Champion (456)

Imagen del wouter_

17-02-2021, 19:17

In my earlier reply I showed that:
a) openMSX can handle paths with backslashes, as long as you can get the backslashes to openMSX.
b) to do this you need to escape the backslash characters (replace each '\' with '\\').

'Turbor' just showed an alternative (easier) way to escape backslashes: just enclose the whole path in {}. But because of a) just enclosing the path with {} is sufficient. No need for the extra 'fromdos - regsub' stuff.

I'm not sure what to think about pgimeno's suggestion for a add-escaping-on-paste setting. It can work for simple things like paths with backslashes, but it will break on more complex scripts. Also it still won't work for paths with spaces (there's no way to know if a space separates a command from an argument, or if a space character is part of a filename). But maybe the solution with {} is sufficient? No need anymore for an escape-on-paste setting?

Por pgimeno

Champion (288)

Imagen del pgimeno

22-02-2021, 22:18

The problem with using {} for strings is that it doesn't have a means for quoting unbalanced braces. Granted, these are extremely rare in filenames, but it's possible to have a need for pasting other texts. The use case is probably too unusual to be worth implementing, though.