Skip to content

Commit 8b414dd

Browse files
committed
TrimHandler: misc. fixes.
- Escape ` for powershell. - Trim trailing whitespace from encoding command so apparently empty commands don't cause problems.
1 parent 3158de1 commit 8b414dd

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/TrimHandler.moon

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bit = require 'bit'
55
windows = ffi.os == "Windows"
66

77
class TrimHandler
8-
@version: 0x010000
8+
@version: 0x010001
99
@version_major: bit.rshift( @version, 16 )
1010
@version_minor: bit.band( bit.rshift( @version, 8 ), 0xFF )
1111
@version_patch: bit.band( @version, 0xFF )
@@ -53,6 +53,7 @@ class TrimHandler
5353
-- }
5454
new: ( trimConfig ) =>
5555
@tokens = { }
56+
trimConfig.command = trimConfig.command\gsub "[\t \r\n]*$", ""
5657
if trimConfig.command != nil and trimConfig.command != ""
5758
@command = trimConfig.command
5859
else
@@ -100,6 +101,7 @@ class TrimHandler
100101
[true]: {
101102
pre: @tokens.temp
102103
ext: ".ps1"
104+
-- This needs to be run from cmd or it will not work.
103105
exec: 'powershell -c iex "$(gc "%s" -en UTF8)"'
104106
preCom: (@makePrefix and "mkdir -Force \"#{@tokens.prefix}\"; & " or "& ")
105107
postCom: (@writeLog and " 2>&1 | Out-File #{@tokens.log} -en UTF8; exit $LASTEXITCODE" or "; exit $LASTEXITCODE")
@@ -141,6 +143,8 @@ class TrimHandler
141143
unless encodeScriptFile
142144
log.windowError "Encoding script could not be written.\nSomething is wrong with your temp dir (#{.pre})."
143145
encodeString = .preCom .. @command\gsub( "#{(.-)}", ( token ) -> @tokens[token] ) .. .postCom
146+
if windows
147+
encodeString = encodeString\gsub "`", "``"
144148
log.debug encodeString
145149
encodeScriptFile\write encodeString
146150
encodeScriptFile\close!

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"src/ShakeShapeHandler.moon": "0x010000",
1111
"src/Tags.moon": "0x010100",
1212
"src/Transform.moon": "0x010000",
13-
"src/TrimHandler.moon": "0x010000",
13+
"src/TrimHandler.moon": "0x010001",
1414
"Aegisub-Motion.moon": "0x010000"
1515
}

0 commit comments

Comments
 (0)