Windows Terminal and !S

Advertisement

user564758
Joined:
Posts:
19

Windows Terminal and !S

I am passing !S via an extension file and there is a semicolon in the result that is confusing Windows Terminal

sftp://username;fingerprint=ssh-ed25519-MYKEY@IP

I am passing it to bash.exe and it splits the positional parameters at fingerprint=ssh-ed25519-MYKEY@IP

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

Re: Windows Terminal and !S

Can you please share more details? I do not understand the connection to bash and Windows Terminal.

Reply with quote

user564758
Joined:
Posts:
19

It's nothing to do with bash really, this is a Windows Terminal problem and there are other posts here about Windows Terminal mangling semi colons.

The password one is encoded but this session URL is not and the semi colon is causing Windows Terminal to split the output.

wt load/bash.exe -lis "!S"

Reply with quote

martin
Site Admin
martin avatar

OK, I see. What do you suggest WinSCP should do about it? I didn't find a way to escape the semicolons in Windows Terminal commandline. Is there? If not, it's something you should ask them to do.

Reply with quote

user564758
Joined:
Posts:
19

The only thing I can think WinSCP can do is encode the entire string like it does with passwords or provide an option to do it. If it was encoded I could decode it client side in my script.

Otherwise I guess the fix has to be at their end. Like a flag to ignore ;

Or use a mediator (cmd/bash) that opens wt after the string is processed instead of trying to pass it directly to wt

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

The encoding cannot work. The point of the encoding is to encode the characters in passwords (and similar) parts of the URL that have otherwise special meaning to WinSCP. If you encode the semicolon, it would become part of the password. It would have to be yet another kind of encoding. But that can be hardly universal. Every app have different special characters.

But the "mediator" would indeed work. Either wrap your final command/script to yet another script. Or use the !`command` pattern. For example:
wt load/bash.exe -lis !`powershell -ExecutionPolicy Bypass -Command '!S' -replace ';', '_'"`
And then in your final extension script, reverse the replacement/encoding.

Reply with quote

user564758
Joined:
Posts:
19

I think there is a misunderstanding about why think encoding is an option to me. All I want, essentially, is do this
# @command cmd /c start "" wt nt --title LFTP4WIN "%WINSCP_PATH%\..\..\bin\bash.exe" "-lis" "%EXTENSION_PATH%" "!U" "!@" "!#" "!/" "!\"

So in my particular use case passing the password with a semicolon is fine because I decode this positional parameter via a function
password="$(printf %b "$(printf %s "${4//\%/\\x}" | cut -f3 -d":" | cut -f1 -d";" | cut -f1 -d"@")")"

So the point is that is !S was encoded like !P or had the option to be encoded, maybe for all session parameters, it could be passed as I just showed and then decoded by the bash script extension to be used.

That so why having it encoded would work for me here. Otherwise I would need to mediate. I hope this makes sense to why I think maybe having an option to encode this or maybe all session vars could be useful.

Reply with quote

martin
Site Admin
martin avatar

I do not see any misunderstanding. Though I do not understand "So the point is that is !S was encoded like !P"!P is not encoded anyhow.

Anyway, I've shown you in my previous post, how to implement the "encoding".

Reply with quote

Advertisement

You can post new topics in this forum