aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-02 15:38:37 +0000
committerRoy Marples <roy@marples.name>2008-01-02 15:38:37 +0000
commitfadee8e656807f466cdf39a9a9c0c113613bc36d (patch)
tree1179d0acb5e063621467654263e978274ec387dd /src
parente5933843e81b213786f78bb267f84fa78f663b61 (diff)
Move _shell_var shell function to shell_var C applet
Diffstat (limited to 'src')
-rw-r--r--src/Makefile3
-rw-r--r--src/rc.c25
2 files changed, 27 insertions, 1 deletions
diff --git a/src/Makefile b/src/Makefile
index c4e9268a..7b9d5319 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -69,7 +69,8 @@ RC_BINLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
service_inactive service_wasinactive \
service_coldplugged service_started_daemon \
checkpath fstabinfo mountinfo rc-depend \
- service_get_value service_set_value get_options save_options
+ service_get_value service_set_value get_options save_options \
+ shell_var
RC_SBINLINKS = mark_service_starting mark_service_started \
mark_service_stopping mark_service_stopped \
mark_service_inactive mark_service_wasinactive \
diff --git a/src/rc.c b/src/rc.c
index f8c2211b..1bdf588e 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -457,6 +457,28 @@ static int do_value (int argc, char **argv)
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
+static int do_shell_var (int argc, char **argv)
+{
+ int i;
+
+ for (i = 0; i < argc; i++) {
+ char *p = argv[i];
+
+ if (i != 0)
+ putchar (' ');
+
+ while (*p) {
+ char c = *p++;
+ if (! isalnum (c))
+ c = '_';
+ putchar (c);
+ }
+ }
+ putchar ('\n');
+
+ return (EXIT_SUCCESS);
+}
+
#ifdef __linux__
static char *proc_getent (const char *ent)
{
@@ -903,6 +925,9 @@ int main (int argc, char **argv)
else if (strcmp (applet, "is_runlevel_stop") == 0)
exit (rc_runlevel_stopping () ? 0 : 1);
+ if (strcmp (applet, "shell_var") == 0)
+ exit (do_shell_var (argc, argv));
+
if (strcmp (applet, "rc-abort") == 0) {
char *p = getenv ("RC_PID");
pid_t pid = 0;