Skip to content

Commit

Permalink
TrimHandler: misc. fixes.
Browse files Browse the repository at this point in the history
- Escape ` for powershell.
- Trim trailing whitespace from encoding command so apparently empty
commands don't cause problems.
  • Loading branch information
torque committed Dec 25, 2014
1 parent 3158de1 commit 8b414dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/TrimHandler.moon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bit = require 'bit'
windows = ffi.os == "Windows"

class TrimHandler
@version: 0x010000
@version: 0x010001
@version_major: bit.rshift( @version, 16 )
@version_minor: bit.band( bit.rshift( @version, 8 ), 0xFF )
@version_patch: bit.band( @version, 0xFF )
Expand Down Expand Up @@ -53,6 +53,7 @@ class TrimHandler
-- }
new: ( trimConfig ) =>
@tokens = { }
trimConfig.command = trimConfig.command\gsub "[\t \r\n]*$", ""
if trimConfig.command != nil and trimConfig.command != ""
@command = trimConfig.command
else
Expand Down Expand Up @@ -100,6 +101,7 @@ class TrimHandler
[true]: {
pre: @tokens.temp
ext: ".ps1"
-- This needs to be run from cmd or it will not work.
exec: 'powershell -c iex "$(gc "%s" -en UTF8)"'
preCom: (@makePrefix and "mkdir -Force \"#{@tokens.prefix}\"; & " or "& ")
postCom: (@writeLog and " 2>&1 | Out-File #{@tokens.log} -en UTF8; exit $LASTEXITCODE" or "; exit $LASTEXITCODE")
Expand Down Expand Up @@ -141,6 +143,8 @@ class TrimHandler
unless encodeScriptFile
log.windowError "Encoding script could not be written.\nSomething is wrong with your temp dir (#{.pre})."
encodeString = .preCom .. @command\gsub( "#{(.-)}", ( token ) -> @tokens[token] ) .. .postCom
if windows
encodeString = encodeString\gsub "`", "``"
log.debug encodeString
encodeScriptFile\write encodeString
encodeScriptFile\close!
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"src/ShakeShapeHandler.moon": "0x010000",
"src/Tags.moon": "0x010100",
"src/Transform.moon": "0x010000",
"src/TrimHandler.moon": "0x010000",
"src/TrimHandler.moon": "0x010001",
"Aegisub-Motion.moon": "0x010000"
}

0 comments on commit 8b414dd

Please sign in to comment.