aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.7.template28
-rw-r--r--src/parser.cpp20
-rw-r--r--src/spawn.cpp5
3 files changed, 42 insertions, 11 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template
index eab26e5..9b31c7d 100644
--- a/doc/sciteco.7.template
+++ b/doc/sciteco.7.template
@@ -1398,9 +1398,12 @@ When \fB^V\fP is not followed by \fB^V\fP, a single character
.BI ^W c
Analogous to \fB^V\fP, but upper-cases characters.
.TP
-.BI ^EQ q
-Expands to the string contents of the Q-Register specified by
-\fIq\fP.
+.BI ^E\(rs q
+Expands to the formatted number stored in the
+numeric part of Q-Register \fIq\fP.
+The number is formatted according to the current
+radix and exactly the same as the backslash (\fB\(rs\fP)
+command would format it.
Currently, long Q-Register names have a separate independant
level of string building character processing, allowing you
to build Q-Register names whose content is then expanded.
@@ -1411,12 +1414,19 @@ part of Q-Register \fIq\fP.
For instance if register \(lqA\(rq contains the code 66,
\(lq^EUa\(rq expands to the character \(lqB\(rq.
.TP
-.BI ^E\(rs q
-Expands to the formatted number stored in the
-numeric part of Q-Register \fIq\fP.
-The number is formatted according to the current
-radix and exactly the same as the backslash (\fB\(rs\fP)
-command would format it.
+.BI ^EQ q
+Expands to the string contents of the Q-Register specified by
+\fIq\fP.
+.TP
+.BI ^E@ q
+Expands to the quoted string contents of the Q-Register
+specified by \fIq\fP.
+The quoting will be such that an UNIX98 \(lq/bin/sh\(rq will
+interpret the quoted string like the original contents of
+\fIq\fP.
+This is useful when generating UNIX shell code or when passing
+registers with unknown contents as parameters to external
+commands using the \fBEC\fP command.
.TP
.BI ^E c
All remaining \fB^E\fP combinations are passed down
diff --git a/src/parser.cpp b/src/parser.cpp
index f05f167..941db49 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -388,6 +388,7 @@ bool
StringBuildingMachine::input(gchar chr, gchar *&result)
{
QRegister *reg;
+ gchar *str;
switch (mode) {
case MODE_UPPER:
@@ -450,13 +451,17 @@ StateCtlE:
undo.push_obj(qregspec_machine) = new QRegSpecMachine;
set(&&StateCtlENum);
break;
+ case 'U':
+ undo.push_obj(qregspec_machine) = new QRegSpecMachine;
+ set(&&StateCtlEU);
+ break;
case 'Q':
undo.push_obj(qregspec_machine) = new QRegSpecMachine;
set(&&StateCtlEQ);
break;
- case 'U':
+ case '@':
undo.push_obj(qregspec_machine) = new QRegSpecMachine;
- set(&&StateCtlEU);
+ set(&&StateCtlEQuote);
break;
default:
result = (gchar *)g_malloc(3);
@@ -497,6 +502,17 @@ StateCtlEQ:
result = reg->get_string();
return true;
+StateCtlEQuote:
+ if (!qregspec_machine->input(chr, reg))
+ return false;
+
+ undo.push_obj(qregspec_machine) = NULL;
+ set(StateStart);
+ str = reg->get_string();
+ result = g_shell_quote(str);
+ g_free(str);
+ return true;
+
StateEscaped:
set(StateStart);
result = String::chrdup(chr);
diff --git a/src/spawn.cpp b/src/spawn.cpp
index 9ea3919..0722180 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -209,6 +209,11 @@ parse_shell_command_line(const gchar *cmdline, GError **error)
* \(lq0,128ED\(rq, and is recommended when writing cross-platform
* macros using the EC command.
*
+ * When using an UNIX-compatible shell or the UNIX98 shell emulation,
+ * you might want to use the \fB^E@\fP string-building character
+ * to pass Q-Register contents reliably as single arguments to
+ * the spawned process.
+ *
* The spawned process inherits both \*(ST's current working
* directory and its environment variables.
* More precisely, \*(ST uses its environment registers