Hi,

> ... ignoring both leading spaces and leading tabs. eg.

Something like (there must be nothing but tabulation before closing ``EOF'')?

  func(){
    sed 's/^ \{2\}//' <<- EOF
      blabla
          EOF
  }

Depending on how and why, there is a lot of *variants*:
 - leading spaces and/or/not leading tabs
 - trailing spaces and/or/not trailing tabs
 - keeping rest of line structure as is or replacing every number of
     spaces/tabs by one space
 - ...

Even merging lines like `xargs` does, there is a way I've used in some scripts,
  ( like https://f-hauri.ch/vrac/live-install.sh.txt ):

   myXargs() { sed -ne '/#/d;s/ \t//g;H;${x;s/\n/ /g;s/^ //;p}'; }

   This drop lines containing `#`, every spaces and merge all line as space
   separated words. I use this as:

   ExtraBootParams=$(myXargs <<-eobp
           boot=live
           config
           #       locales=de_CH
           locales=fr_CH
           keyboard-layouts=ch
           keyboard-variant=fr
           persistent=cryptsetup
           persistence-encryption=luks
           persistence
           eobp
   )
   PackageList=$(myXargs <<-eopl
           gnome
           gnome-core
           # gnome-full
           # debian-forensics
           debian-installer-launcher
           eopl
   )

On Mon, Aug 30, 2021 at 10:06:37PM +0200, Přemysl Šťastný wrote:
> 
> I think, it would be nice, if you implemented Squiggly heredoc, which solves
> this problem by ignoring both leading spaces and leading tabs. eg.
> 
> func()(
>   cat <<~ EOF
>     blabla
>   EOF
> )
> 


-- 
 Félix Hauri  -  <fe...@f-hauri.ch>  -  http://www.f-hauri.ch

Reply via email to