diff --git a/website/scripts/escape.groovy b/website/scripts/escape.groovy index ef269c85..9d83b92b 100644 --- a/website/scripts/escape.groovy +++ b/website/scripts/escape.groovy @@ -2,12 +2,12 @@ def escapeShell(String arg) { - return arg.replaceAll(/["$`<>^\\"']/, /\\$0/) + return '"' + arg.replaceAll(/["$`<>^\\"']/, /\\$0/) + '"' } -if (java.awt.GraphicsEnvironment.headless) { +if (java.awt.GraphicsEnvironment.headless && console != null) { // CLI mode console.printf('Enter: ') def s = console.readLine() @@ -16,7 +16,7 @@ if (java.awt.GraphicsEnvironment.headless) { } else { // GUI mode new groovy.swing.SwingBuilder().edt { - frame(title: 'Escape', size: [350, 230], show: true, defaultCloseOperation: javax.swing.JFrame.EXIT_ON_CLOSE) { + frame(title: 'Escape Tool', size: [350, 230], show: true, defaultCloseOperation: javax.swing.JFrame.EXIT_ON_CLOSE) { gridLayout(cols: 1, rows: 2) textArea id: 'value', lineWrap: true, font: new java.awt.Font('Monospaced', 0, 16) textArea id: 'escape', lineWrap: true, text: bind(source:value, sourceProperty:'text', converter: { escapeShell(it) }), font: new java.awt.Font('Monospaced', 0, 16)