Browse Source

clish_plugin: Add two debug syms clish_print_script(), clish_print_var()

Serj Kalichev 3 years ago
parent
commit
482ddff88d
3 changed files with 36 additions and 0 deletions
  1. 2 0
      plugins/clish/builtin_init.c
  2. 2 0
      plugins/clish/private.h
  3. 32 0
      plugins/clish/sym_misc.c

+ 2 - 0
plugins/clish/builtin_init.c

@@ -32,6 +32,8 @@ CLISH_PLUGIN_INIT(clish)
 	clish_plugin_add_osym(plugin, clish_script, "clish_script");
 	clish_plugin_add_psym(plugin, clish_machine_interface, "clish_machine_interface");
 	clish_plugin_add_psym(plugin, clish_human_interface, "clish_human_interface");
+	clish_plugin_add_psym(plugin, clish_print_script, "clish_print_script");
+	clish_plugin_add_psym(plugin, clish_print_var, "clish_print_var");
 
 	clish_shell = clish_shell; /* Happy compiler */
 

+ 2 - 0
plugins/clish/private.h

@@ -23,3 +23,5 @@ CLISH_PLUGIN_OSYM(clish_script);
 CLISH_PLUGIN_SYM(clish_macros);
 CLISH_PLUGIN_SYM(clish_machine_interface);
 CLISH_PLUGIN_SYM(clish_human_interface);
+CLISH_PLUGIN_SYM(clish_print_script);
+CLISH_PLUGIN_SYM(clish_print_var);

+ 32 - 0
plugins/clish/sym_misc.c

@@ -245,5 +245,37 @@ CLISH_PLUGIN_SYM(clish_human_interface)
 	return 0;
 }
 
+/*----------------------------------------------------------- */
+/*
+ * Builtin: Print script
+ */
+CLISH_PLUGIN_SYM(clish_print_script)
+{
+	printf("%s\n", script);
+
+	out = out; /* Happy compiler */
+	clish_context = clish_context; /* Happy compiler */
+
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+/*
+ * Builtin: Print param
+ */
+CLISH_PLUGIN_SYM(clish_print_var)
+{
+	char *str = NULL;
+
+	// Script contains variable name
+	str = clish_shell_expand_var(script, clish_context);
+	printf("%s\n", str);
+	lub_string_free(str);
+
+	out = out; /* Happy compiler */
+	clish_context = clish_context; /* Happy compiler */
+
+	return 0;
+}
 
 /*----------------------------------------------------------- */