* include leading/trailing argument quotes

This commit is contained in:
Reinhard Pointner 2013-10-25 06:40:40 +00:00
parent 32fe29653e
commit d609a1a080
1 changed files with 3 additions and 3 deletions

View File

@ -2,12 +2,12 @@
def escapeShell(String arg) { 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 // CLI mode
console.printf('Enter: ') console.printf('Enter: ')
def s = console.readLine() def s = console.readLine()
@ -16,7 +16,7 @@ if (java.awt.GraphicsEnvironment.headless) {
} else { } else {
// GUI mode // GUI mode
new groovy.swing.SwingBuilder().edt { 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) gridLayout(cols: 1, rows: 2)
textArea id: 'value', lineWrap: true, font: new java.awt.Font('Monospaced', 0, 16) 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) textArea id: 'escape', lineWrap: true, text: bind(source:value, sourceProperty:'text', converter: { escapeShell(it) }), font: new java.awt.Font('Monospaced', 0, 16)