Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #268810 > unrolled thread

Re: config files - newline possible?

Started by<tomas@tuxteam.de>
First post2024-04-11 20:30 +0200
Last post2024-04-11 20:50 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: config files - newline possible? <tomas@tuxteam.de> - 2024-04-11 20:30 +0200
    Re: config files - newline possible? Greg Wooledge <greg@wooledge.org> - 2024-04-11 20:50 +0200
      [SOLVED] Re: config files - newline possible? Hans <hans.ullrich@loop.de> - 2024-04-11 21:40 +0200
    Re: config files - newline possible? Hans <hans.ullrich@loop.de> - 2024-04-11 20:50 +0200

#268810 — Re: config files - newline possible?

From<tomas@tuxteam.de>
Date2024-04-11 20:30 +0200
SubjectRe: config files - newline possible?
Message-ID<Is7ln-5ClR-9@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

On Thu, Apr 11, 2024 at 05:56:05PM +0200, Hans wrote:
> Hi folks, 
> 
> O know in shell scripts it is possible, to seperate a looong line of commands 
> into several short lines.
> 
> But can this be done in config-files, too?
> 
> I have a files with the syntax like this:
> 
> Do_not_write="/path1/subfolder /path1/subfolder2 ... /pathX/subfolderX"

As Nicolas George says, "config-file" is too generic a term.
If the above is a variable assignment, then you can escape the
newlines with a backslash, like so

Do_not_write="path1/subfolder \
  path1/subfolder2 \
  ..."

Note that the backslash has to be the last character in the
line. No extra whitespace after that (this is somewhat
fragile). I prefer to put such things in here docs:

read -d '' Do_not_write <<"__END"
this
that
the other
__END

echo "Do_not_write"
=>
this
that
the other

Put attention to the quotes. In bash, type "help read" to learn
about the options (it is a builtin, it has to).

Cheers
-- 
t

[toc] | [next] | [standalone]


#268821

FromGreg Wooledge <greg@wooledge.org>
Date2024-04-11 20:50 +0200
Message-ID<Is7EJ-5Cso-1@gated-at.bofh.it>
In reply to#268810
On Thu, Apr 11, 2024 at 08:42:20PM +0200, Hans wrote:
> in my case it is the config freom from bootcdwrite, which is bootcdwrite.conf.

<https://manpages.debian.org/bookworm/bootcd/bootcdwrite.conf.5.en.html>
says:

    This file will be sourced as shell file.

So, you may use any valid "shell" (presumably sh) syntax, including
backslash-newline for continuation.

[toc] | [prev] | [next] | [standalone]


#268823 — [SOLVED] Re: config files - newline possible?

FromHans <hans.ullrich@loop.de>
Date2024-04-11 21:40 +0200
Subject[SOLVED] Re: config files - newline possible?
Message-ID<Is8r7-5CYJ-3@gated-at.bofh.it>
In reply to#268821
Hi Greg,
ah, I wasn't aware of this. This is really great news! And it will help me 
much. 

You made my day! Thank you very much.

Best regards

Hans 
> On Thu, Apr 11, 2024 at 08:42:20PM +0200, Hans wrote:
> > in my case it is the config freom from bootcdwrite, which is
> > bootcdwrite.conf.
> <https://manpages.debian.org/bookworm/bootcd/bootcdwrite.conf.5.en.html>
> says:
> 
>     This file will be sourced as shell file.
> 
> So, you may use any valid "shell" (presumably sh) syntax, including
> backslash-newline for continuation.

[toc] | [prev] | [next] | [standalone]


#268822

FromHans <hans.ullrich@loop.de>
Date2024-04-11 20:50 +0200
Message-ID<Is7EJ-5Cso-3@gated-at.bofh.it>
In reply to#268810
Hi Tomas,

in my case it is the config freom from bootcdwrite, which is bootcdwrite.conf.

The parm is NOT_TO_CD and as there are many and partly long pathnames, the 
line has increased rather long. So I want to shorten it.

But as it was said: there is no general way for this. So I just try some 
things out for this, and the next time again.

Thought I have something missed, but does not look so.

Thanks for all the help, I think this case caqn be closed. I will wait for one 
or two days and then mark this case as closed.

Cheers

Hans

> As Nicolas George says, "config-file" is too generic a term.
> If the above is a variable assignment, then you can escape the
> newlines with a backslash, like so
> 
> Do_not_write="path1/subfolder \
>   path1/subfolder2 \
>   ..."
> 
> Note that the backslash has to be the last character in the
> line. No extra whitespace after that (this is somewhat
> fragile). I prefer to put such things in here docs:
> 
> read -d '' Do_not_write <<"__END"
> this
> that
> the other
> __END
> 
> echo "Do_not_write"
> =>
> this
> that
> the other
> 
> Put attention to the quotes. In bash, type "help read" to learn
> about the options (it is a builtin, it has to).
> 
> Cheers

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web