Skip to content

Transportable Cat? #1499

Answered by WesselAtWork
WesselAtWork asked this question in Q&A
Feb 7, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

echo $(<)

echo "$(<backup.txt)"


Figured it out!

Becuase go-task uses mvdan/sh as it's command runner I just needed to use bashy contructs to get the file contents.

My original problem

Sadly I cant do echo "$(<backup.txt)" || echo "works", the bashism fails in the interpreter [ :( ]

Needed to add a test:

some-task:
  desc: "Mock Minimal Cat"
  vars:
    MY_VLAUE:
      sh: '[ -f backup.txt ] && echo "$(<backup.txt)" || echo "my one-ish time command"'
  cmd: 
    - 'echo "{{.MY_VALUE}}" > backup.txt '
    - 'echo "{{.MY_VALUE}} -- command failure sim" && false' 
    - 'rm -f backup.txt'

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@WesselAtWork
Comment options

@WesselAtWork
Comment options

Answer selected by WesselAtWork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant