Skip to content

Re-implement ad6ae240 without behavior change #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tasks/read_file.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@
}
},
"implementations": [
{"name": "read_file.rb", "requirements": ["puppet-agent"], "input_method": "stdin"},
{"name": "read_file.sh", "requirements": ["shell"], "input_method": "environment"}
]
}
20 changes: 0 additions & 20 deletions tasks/read_file.rb

This file was deleted.

23 changes: 12 additions & 11 deletions tasks/read_file.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#!/bin/bash

main() {
local python_exec=""

# check if any python exec is available on the remote system. error out if not
while :; do
python_exec=$(command -v python) && break
python_exec=$(command -v python3) && break
python_exec=$(command -v python2) && break
echo "Error: No Python version 2 or 3 interpreter found."
exit 1
done

if [ -r "$PT_path" ]; then
cat <<-EOS
{
"content": $(python_cmd -c "import json; print json.dumps(open('$PT_path','r').read())")
"content": $($python_exec -c "import json; print json.dumps(open('$PT_path','r').read())")
}
EOS
else
@@ -17,14 +28,4 @@ main() {
fi
}

python_cmd() {
if command -v python >/dev/null 2>&1; then
python "$@"
else
python3 "$@"
fi
}

main "$@"
exit_code=$?
exit $exit_code