mrbaseman / parse_yaml

a simple yaml parser implemented in bash
GNU General Public License v3.0
165 stars 37 forks source link

Parseing YAML issue #25

Open nctiggy opened 6 months ago

nctiggy commented 6 months ago

Hi, Thanks for your wonderful function! I have the following yaml

---
tools:
  - name: fly
    version_command: "fly --version"
    minimum_version: "5.6"
  - name: docker
    version_command: "docker --version | awk -F'[, ]' '{print $3}' | awk -F'[-]' '{print $1}'"
    minimum_version: "24.0"

When I parse the docker version command the first awk command loses some info. In particular the comma and the following space. Any way to work around this?

docker --version | awk -F'[]' '{print $3}' | awk -F'[-]' '{print $1}'
mrbaseman commented 5 months ago

hmm... a dirty trick: just escape the square brackets with a backslash and ignore the warnings which awk throws about them: version_command: "docker --version | awk -F'\[, \]' '{print $3}' | awk -F'\[-\]' '{print $1}'"