Skip to content

Instantly share code, notes, and snippets.

@holybit
Last active January 13, 2017 20:59
Show Gist options
  • Save holybit/c1a68add15bd15bc9f9c6d146019e649 to your computer and use it in GitHub Desktop.
Save holybit/c1a68add15bd15bc9f9c6d146019e649 to your computer and use it in GitHub Desktop.
bash cli command not working
$ bash --version
GNU bash, version 4.3.46(1)-release (x86_64-cros-linux-gnu)
...
$ pwd
/tmp
$ /bin/bash -c echo -e "{\n \"credStore\": \"ecr-login\"\n}" >> /tmp/config.json
$ cat config.json
# /tmp/config.json has one blank line
# What I want in /tmp/config.json is the following
{
"credStore": "ecr-login"
}
# Questions you might ask
# 1. Why in the heck are you using bash -c?
# This is being run from an ExecStart as part of a SystemD service unit. Given I have to redirect the echo output
# to a file I can not use "/bin/echo ..." as redirect is not allowed.
# https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines
# | This syntax is intended to be very similar to shell syntax, but only the meta-characters and expansions described in the following paragraphs are understood. Specifically, redirection using "<", "<<", ">", and ">>", pipes using "|", running programs in the background using "&", and other elements of shell syntax are not supported.
# 2. Why not copy a shell script onto the machine instead of this one liner?
# TL;DR given it's an CoreOS Container Linux machine being spun up in AWS a oneliner ExecStart is easiest way forward.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment