summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--plugins/shell.py18
-rw-r--r--test/Vagrantfile2
-rw-r--r--test/tests/shell-compact-stdout.bash22
-rw-r--r--test/tests/shell-override-default.bash14
5 files changed, 50 insertions, 7 deletions
diff --git a/README.md b/README.md
index c58debc..1d6e938 100644
--- a/README.md
+++ b/README.md
@@ -265,6 +265,7 @@ command itself.
command: read var && echo Your variable is $var
stdin: true
stdout: true
+ description: Reading and printing variable
-
command: read fail
stderr: true
diff --git a/plugins/shell.py b/plugins/shell.py
index 2931dc2..b6f5184 100644
--- a/plugins/shell.py
+++ b/plugins/shell.py
@@ -22,15 +22,21 @@ class Shell(dotbot.Plugin):
with open(os.devnull, 'w') as devnull:
for item in data:
stdin = stdout = stderr = devnull
+ if defaults.get('stdin', False) == True:
+ stdin = None
+ if defaults.get('stdout', False) == True:
+ stdout = None
+ if defaults.get('stderr', False) == True:
+ stderr = None
if isinstance(item, dict):
cmd = item['command']
msg = item.get('description', None)
- if item.get('stdin', defaults.get('stdin', False)) is True:
- stdin = None
- if item.get('stdout', defaults.get('stdout', False)) is True:
- stdout = None
- if item.get('stderr', defaults.get('stderr', False)) is True:
- stderr = None
+ if 'stdin' in item:
+ stdin = None if item['stdin'] == True else devnull
+ if 'stdout' in item:
+ stdout = None if item['stdout'] == True else devnull
+ if 'stderr' in item:
+ stderr = None if item['stderr'] == True else devnull
elif isinstance(item, list):
cmd = item[0]
msg = item[1] if len(item) > 1 else None
diff --git a/test/Vagrantfile b/test/Vagrantfile
index 6d3feb0..8ce1739 100644
--- a/test/Vagrantfile
+++ b/test/Vagrantfile
@@ -1,5 +1,5 @@
Vagrant.configure(2) do |config|
- config.vm.box = 'debian/jessie64'
+ config.vm.box = 'debian/stretch64'
# sync by copying for isolation
config.vm.synced_folder "..", "/dotbot", type: "rsync",
diff --git a/test/tests/shell-compact-stdout.bash b/test/tests/shell-compact-stdout.bash
new file mode 100644
index 0000000..dc55d52
--- /dev/null
+++ b/test/tests/shell-compact-stdout.bash
@@ -0,0 +1,22 @@
+test_description='shell command stdout works in compact form'
+. '../test-lib.bash'
+
+test_expect_success 'run' '
+(run_dotbot | grep "^apple") <<EOF
+- defaults:
+ shell:
+ stdout: true
+- shell:
+ - echo apple
+EOF
+'
+
+test_expect_success 'run 2' '
+(run_dotbot | grep "^apple") <<EOF
+- defaults:
+ shell:
+ stdout: true
+- shell:
+ - [echo apple, "echoing message"]
+EOF
+'
diff --git a/test/tests/shell-override-default.bash b/test/tests/shell-override-default.bash
new file mode 100644
index 0000000..8ca6264
--- /dev/null
+++ b/test/tests/shell-override-default.bash
@@ -0,0 +1,14 @@
+test_description='shell command can override default'
+. '../test-lib.bash'
+
+test_expect_success 'run' '
+(run_dotbot | (! grep "^apple")) <<EOF
+- defaults:
+ shell:
+ stdout: true
+- shell:
+ -
+ command: echo apple
+ stdout: false
+EOF
+'