aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-13 16:27:42 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-13 16:27:42 +0300
commit7c1c6e24da6aab969c25ab5d326dd93cc2cb8149 (patch)
tree2264c784a4e531e7adf25d1b69173f8513babc19
parentfe62b2451ac200f846a5bae1d08ec9c3201e26c9 (diff)
downloadsciteco-7c1c6e24da6aab969c25ab5d326dd93cc2cb8149.tar.gz
fixed <EC$> assertions: specifying empty command strings was undefined
* passing an empty command string down to the shell would always do nothing, so it doesn't make sense to support that. * for the time being, we generate a proper error * in the future, it might make sense to define some special behavior like repeating the last command - but EC does not currently save the command line anywhere. * The generated documentation is currently ugly (FIXME). mandatory parameters are not properly detected by tedoc and we cannot keep apart Q-Registers from mandatory parameters either. Also, we should allow <param> markup in command summaries.
-rw-r--r--src/spawn.c37
-rw-r--r--tests/testsuite.at5
2 files changed, 23 insertions, 19 deletions
diff --git a/src/spawn.c b/src/spawn.c
index 7515fd6..00394e3 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -257,12 +257,11 @@ teco_state_execute_done(teco_machine_main_t *ctx, const teco_string_t *str, GErr
g_autoptr(GIOChannel) stdin_chan = NULL, stdout_chan = NULL;
g_auto(GStrv) argv = NULL, envp = NULL;
- if (teco_string_contains(str, '\0')) {
+ if (!str->len || teco_string_contains(str, '\0')) {
g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Command line must not contain null-bytes");
+ "Command line must not be empty or contain null-bytes");
goto gerror;
}
- g_assert(str->data != NULL);
argv = teco_parse_shell_command_line(str->data, error);
if (!argv)
@@ -413,14 +412,14 @@ cleanup:
gboolean teco_state_execute_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *parent_ctx, gchar key, GError **error);
/*$ EC pipe filter
- * EC[command]$ -- Execute operating system command and filter buffer contents
- * linesEC[command]$
- * -EC[command]$
- * from,toEC[command]$
- * :EC[command]$ -> Success|Failure
- * lines:EC[command]$ -> Success|Failure
- * -:EC[command]$ -> Success|Failure
- * from,to:EC[command]$ -> Success|Failure
+ * ECcommand$ -- Execute operating system command and filter buffer contents
+ * linesECcommand$
+ * -ECcommand$
+ * from,toECcommand$
+ * :ECcommand$ -> Success|Failure
+ * lines:ECcommand$ -> Success|Failure
+ * -:ECcommand$ -> Success|Failure
+ * from,to:ECcommand$ -> Success|Failure
*
* The EC command allows you to interface with the operating
* system shell and external programs.
@@ -546,14 +545,14 @@ teco_state_egcommand_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg,
}
/*$ EG EGq
- * EGq[command]$ -- Set Q-Register to output of operating system command
- * linesEGq[command]$
- * -EGq[command]$
- * from,toEGq[command]$
- * :EGq[command]$ -> Success|Failure
- * lines:EGq[command]$ -> Success|Failure
- * -:EGq[command]$ -> Success|Failure
- * from,to:EGq[command]$ -> Success|Failure
+ * EGq command$ -- Set Q-Register to output of operating system command
+ * linesEGq command$
+ * -EGq command$
+ * from,toEGq command$
+ * :EGq command$ -> Success|Failure
+ * lines:EGq command$ -> Success|Failure
+ * -:EGq command$ -> Success|Failure
+ * from,to:EGq command$ -> Success|Failure
*
* Runs an operating system <command> and set Q-Register
* <q> to the data read from its standard output stream.
diff --git a/tests/testsuite.at b/tests/testsuite.at
index e5b001a..80e111c 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -137,6 +137,11 @@ AT_SETUP([Empty lexer name])
AT_CHECK([$SCITECO -e '@ES/SETILEXER//'], 1, ignore, ignore)
AT_CLEANUP
+AT_SETUP([Empty command string])
+AT_CHECK([$SCITECO -e '@EC//'], 1, ignore, ignore)
+AT_CHECK([$SCITECO -e '@EGa//'], 1, ignore, ignore)
+AT_CLEANUP
+
AT_BANNER([Known Bugs])
AT_SETUP([Number stack])