Skip to content

Commit

Permalink
make command::working_directory optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokin committed Mar 9, 2014
1 parent a0fd84d commit 4018bb6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
36 changes: 12 additions & 24 deletions demo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@ task print_hello = start_stop
{
start = command
{
cmd = "/bin/echo 'welcome to initd demo'",
working_directory = "/"
cmd = "/bin/echo 'welcome to initd demo'",
},

stop = command
{
cmd = "/bin/false",
working_directory = "/"
cmd = "/bin/false",
},
};

task print_hostname_before = start_stop
{
start = command
{
cmd = "/bin/hostname",
working_directory = "/"
cmd = "/bin/hostname",
},

stop = command
{
cmd = "/bin/hostname",
working_directory = "/"
cmd = "/bin/hostname",
},
};

Expand All @@ -38,59 +34,51 @@ task print_hostname_after = start_stop
{
start = command
{
cmd = "/bin/hostname",
working_directory = "/"
cmd = "/bin/hostname",
},

stop = command
{
cmd = "/bin/hostname",
working_directory = "/"
cmd = "/bin/hostname",
},
};

task task_1 = start_stop
{
start = command
{
cmd = "/bin/echo 'task 1 started'",
working_directory = "/"
cmd = "/bin/echo 'task 1 started'",
},

stop = command
{
cmd = "/bin/echo 'task 1 stopped'",
working_directory = "/"
cmd = "/bin/echo 'task 1 stopped'",
},
};

task task_2 = start_stop
{
start = command
{
cmd = "/bin/echo 'task 2 started'",
working_directory = "/"
cmd = "/bin/echo 'task 2 started'",
},

stop = command
{
cmd = "/bin/echo 'task 2 stopped'",
working_directory = "/"
cmd = "/bin/echo 'task 2 stopped'",
},
};

task task_3 = start_stop
{
start = command
{
cmd = "/bin/echo 'task 3 started'",
working_directory = "/"
cmd = "/bin/echo 'task 3 started'",
},

stop = command
{
cmd = "/bin/echo 'task 3 stopped'",
working_directory = "/"
cmd = "/bin/echo 'task 3 stopped'",
},
};

Expand Down
6 changes: 3 additions & 3 deletions libinitd-readconfig/read_value_node/read_value_node_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ boost::optional<command> read_value_node_impl<command>::read(value_node const& n
std::multimap<std::string, property_node*> properties_by_name = make_properties_map(cnode, esink);

boost::optional<cmd_line> cmd = extract_property_from_map<cmd_line>(cnode, properties_by_name, "cmd", esink);
boost::optional<std::string> working_directory = extract_property_from_map<std::string>(cnode, properties_by_name, "working_directory", esink);
if (!cmd || !working_directory)
std::string working_directory = extract_property_from_map<std::string>(cnode, properties_by_name, "working_directory", "/", esink);
if (!cmd)
return boost::none;

command data;

data.cmd = *cmd;
data.working_directory = *working_directory;
data.working_directory = working_directory;

return data;
}
Expand Down
5 changes: 5 additions & 0 deletions test-config/config_tests/task-hostname-5.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
task a = sethostname
{
hostname = "localhost"
no_restore = false
}
4 changes: 4 additions & 0 deletions test-config/config_tests/task-hostname-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
task a = sethostname
{
hostname = "localhost"
};

0 comments on commit 4018bb6

Please sign in to comment.