Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 1.64 KB

how-to-use-a-multiline-string-command-argument-input-and-preserve-the-strings-newlines-in-the-output-using-here-strings-here-documents.md

File metadata and controls

41 lines (26 loc) · 1.64 KB

September 26, 2023 TIL - How to Use a Multiline String Command Argument Input & Preserve the String's Newlines in the Output Using "Here Strings" and/or "Here Documents"

Using "Here Strings"/"Here Documents", we can use multiline strings as command argument inputs while preserving the newlines in the multiline string command output.

Example

Using ankitpokhrel/jira-cli, add a multiline string comment to a Jira Issue & preserve any newlines.

Note: ankitpokhrel/jira-cli supports both Github-flavored and Jira-flavored markdown for writing comments.

# "Here String" Method
$ jira issue comment add --no-input ISSUE-1 "
# GFM Flavor H1

## GFM Flavor H2

- UL List Item 1
- UL List Item 2"

# "Here Document" Method
$ jira issue comment add --no-input ISSUE-1 --template - << EOF
# GFM Flavor H1

## GFM Flavor H2

- UL List Item 1
- UL List Item 2
EOF

Use Cases

  • Use "Here Strings"/"Here Documents" to add multiline strings as command argument inputs while preserving the newlines in the multiline string command output
  • Add multiline string comments to Jira Issues from the CLI using ankitpokhrel/jira-cli + "Here Strings"/"Here Documents"

References