[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file

From: Greg Wooledge
Subject: Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file or directory"
Date: Tue, 29 Jul 2014 15:39:46 -0400
User-agent: Mutt/

On Tue, Jul 29, 2014 at 12:06:41PM -0700, Linda Walsh wrote:
> Andreas Schwab wrote:
> >You need a file descriptor for your memory storage.
> ---
> Why?

A here-document is a redirection.  All it does it change where stdin
comes from.  There has to be a place for file descriptor 0 to point to.
This can be a real file on disk, or one end of a pipe().

I'm not aware of any shells that use a multi-process pipe() implementation
for here-documents.  Maybe this is just historical inertia, or maybe it's
because a temporary file can be lseek()ed, which gives the most flexibility
for the processes that are reading them.  Or maybe it's because a temp
file is considered less of a resource waste than an extra process.

I really do advise you to simplify your boot scripts.  Boot scripts run in
minimalist environments, where advanced features are not always available.
Boot scripts also typically are not run by bash; they're run by /bin/sh
(or even /sbin/sh), which is more likely to be some stripped-down POSIX
shell than it is to be bash.

If you've got some big static block of text that you need to feed to a
daemon at boot time, maybe it would be appropriate to stick this text in
a config file (/etc/default/yourdaemon or /etc/yourdaemon/startup.text or
something like that).  Then you can redirect from that file instead of
using a here-document buried in a boot script.  From a system administration
perspective, this separation of code from data would be a lot cleaner.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]