* include leading/trailing argument quotes
This commit is contained in:
parent
32fe29653e
commit
d609a1a080
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue