Comment

Comment by adrianmonk

You can also use a "here document"

    help() {
      cat <<'EOH'
    my-script — does one thing well
    
    Usage:
      my-script <input> <output>
    
    Options:
      <input>   Input file to read.
      <output>  Output file to write. Use '-' for stdout.
      -h        Show this message.
    EOH
    }
If the indentation bugs you, you can use a simpler sed trick to remove leading space so that you can indent it as desired:

    help() {
      sed -e 's/    //' <<'EOH'
        my-script — does one thing well
        
        Usage:
          my-script <input> <output>
        
        Options:
          <input>   Input file to read.
          <output>  Output file to write. Use '-' for stdout.
          -h        Show this message.
    EOH
    }
parent adrianmonk 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton