Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Mar 2021 15:13:14 -0700
From:      Bob Proulx <>
Subject:   Re: which is "better" - /dev/fd or FIFO
Message-ID:  <>
In-Reply-To: <YETXFrAz3D8DPvYe@ceres.local>
References:  <YEOMzXyvchUkMmdH@ceres.local> <> <YETXFrAz3D8DPvYe@ceres.local>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

tech-lists wrote:
> Thanks for that. It explains partly why it's not enabled by default.
> But I wondered why it's there at all, what is the benefit of that
> functionality (if enabled) over what (in this case, bash-commander) it
> would use in its absence (presumably FIFO)

Twice now you have written /dev/fd or FIFO but I don't see any
connection between those two things.  I don't see a lot of things.
What am I missing?  How is the /dev/fd directory related to bash using
a FIFO?  And FIFO?  Where has a FIFO been mentioned in this thread?

As far as I can tell a default installation of FreeBSD supports the
system level use of /dev/fd and therefore there is no need to have
bash emulation code enabled.  Pretty sure.  Seems like to me.  I
didn't try all of the combinations to prove it.  This following is on
FreeBSD 12 RELEASE.  Since those are real files in the system then any
script for any shell or program may make use of them.

    rwp@outrage:/usr/home/rwp$ ll /dev/fd/
    total 0
    crw-rw-rw-  1 root  wheel  0x1c Feb  7 20:48 0
    crw-rw-rw-  1 root  wheel  0x1e Feb  7 20:48 1
    crw-rw-rw-  1 root  wheel  0x20 Feb  7 20:48 2

    rwp@outrage:/usr/home/rwp$ echo now is the time | cat /dev/fd/0
    now is the time

    rwp@outrage:/usr/home/rwp$ echo now is the time | cat /dev/stdin
    now is the time

Note that the use of /dev/fd is something that a script writer decides
they want to use or not.  It's a new thing in the grand scheme of
geological time and I personally both 1) only rarely ever see its use
in scripts and 2) rather disprove of it because it isn't really a
portable feature.  I have never felt the need to code using it myself.
So personally I would recommend not using it..  I always scrape those
out of scripts whenever I see that people have used them.  YMMV.

Note that bash will internally simulate /dev/fd if a real system one
is not provided.  Pretty sure anyway.  I have definitely used bash and
seen that feature noted even on systems without /dev/fd directory support.

    The /usr/local/share/doc/bash/NEWS file:

        i.  The redirection code now handles several filenames specially:
            /dev/fd/N, /dev/stdin, /dev/stdout, and /dev/stderr, whether or
            not they are present in the file system.

    The /usr/local/share/doc/bash/FAQ file:

        Bash-2.04 introduced the following new features:

        o The redirection code handles several filenames specially:  /dev/fd/N,
          /dev/stdin, /dev/stdout, /dev/stderr

That was bash-2.04 but in 12 Release:

    rwp@outrage:/usr/home/rwp$ type bash
    bash is hashed (/usr/local/bin/bash)

    rwp@outrage:/usr/home/rwp$ bash --version
    GNU bash, version 5.0.11(0)-release (i386-portbld-freebsd12.0)

So it has been a long time now...


Content-Type: application/pgp-signature; name="signature.asc"




Want to link to this message? Use this URL: <>