From owner-freebsd-questions@freebsd.org Sun Mar 7 22:13:24 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4FE24576CE1 for ; Sun, 7 Mar 2021 22:13:24 +0000 (UTC) (envelope-from bob@proulx.com) Received: from havoc.proulx.com (havoc.proulx.com [96.88.95.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dtwhz2gpRz4R0s for ; Sun, 7 Mar 2021 22:13:23 +0000 (UTC) (envelope-from bob@proulx.com) Received: from joseki.proulx.com (localhost [127.0.0.1]) by havoc.proulx.com (Postfix) with ESMTP id 355B6439 for ; Sun, 7 Mar 2021 15:13:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proulx.com; s=dkim2048; t=1615155195; bh=1riGqJyjaNm9mDs8duASoI7nmbhbv83tksRQmUIy5pM=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Co3zLVVeSRo+BQWRsnEOoSqzFLb/lNO56ggIX4rrIyRwxoVsDnzez+0cVUn83JDRL y0yRqaGRzpCm9UjIhNmirJDEhQetIDLA91qy1z40QdkDO3P722lOTU5WpvGAAZ3eHU asbtGFLdwHQiVsbRIwKzlW5KS4aqHSC5pt/nac2bCd8FBU1pZYp/CdT48PDm1J2ShC bnCOpcEJFwpvh6jo85L/EdrfCuGbpsUumnsLGrSzsaLmGyIaE6fxuuS3+01mOrvhoq a9zwcyXvYQiFaNkZy8tky8+GqAAEi+Qe5sCqHytOENfNvK1HNEX2rDcnne409pzzJX pXCkAAKhfcEgw== Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 06BA521166 for ; Sun, 7 Mar 2021 15:13:15 -0700 (MST) Received: by hysteria.proulx.com (Postfix, from userid 1000) id C14752DC9C; Sun, 7 Mar 2021 15:13:14 -0700 (MST) Date: Sun, 7 Mar 2021 15:13:14 -0700 From: Bob Proulx To: freebsd-questions@freebsd.org Subject: Re: which is "better" - /dev/fd or FIFO Message-ID: <20210307145622717830089@bob.proulx.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <20210306204633.3be9720a@gumby.homeunix.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mTAnpWVoLNHHGNT2" Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4Dtwhz2gpRz4R0s X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=proulx.com header.s=dkim2048 header.b=Co3zLVVe; dmarc=pass (policy=none) header.from=proulx.com; spf=pass (mx1.freebsd.org: domain of bob@proulx.com designates 96.88.95.61 as permitted sender) smtp.mailfrom=bob@proulx.com X-Spamd-Result: default: False [-6.09 / 15.00]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[96.88.95.61:from]; R_DKIM_ALLOW(-0.20)[proulx.com:s=dkim2048]; NEURAL_HAM_LONG(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+a]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[96.88.95.61:from:127.0.2.255]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DKIM_TRACE(0.00)[proulx.com:+]; DMARC_POLICY_ALLOW(-0.50)[proulx.com,none]; NEURAL_HAM_SHORT(-0.99)[-0.986]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:7922, ipnet:96.64.0.0/11, country:US]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2021 22:13:24 -0000 --mTAnpWVoLNHHGNT2 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... Bob --mTAnpWVoLNHHGNT2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEY7Fmg4Qc49wl08brQhr6Jjh/mo4FAmBFT/YACgkQQhr6Jjh/ mo4XUw/9H0ICX7jlxV63P3+KPHZvWjQgV8u4w3B22gFpO2Zn3WowCFZRzZ8uvva4 P2otjNfBYng9lgOudkfQYOYzyf1KXZNMj9BRqJPvmMYb26iSurzLICkrYAerDouq EnGR3A/wRcfNSGqkWcD2kzsGdcKPFcgnKaouICe3yAfubY9W2tHwS5P4jY4I6fby cJHkzhc+7ill12Y22ucMi6a3TVD9asFvUp5nNDinwYE4tV7tmKOARvH7f3wBhaTy 5ZKVph9Ow/NmFMigv+GeAbfu/SR+uFfriNhWxHjnFdDqaY8dGIisS4K9wRHWAND1 H7yQaBs4F9N97rgvuz+LMg8vCSIxZP0MSJ6erq059b0LosVE/Qi5cfxq8LSn7ziG kmEbtewjOtFeRwEFCWVSZ+2Ho+wC7JysXEHoN3X2h/v9WMOVTEWf+KrVM9Qvo3o9 n53ZB+bSo3o86vo8r1vFxfolE281KQLf0zzi/Jkx/3Hh7xBXVdSSbhe0lhIasTxX IAK1UemUM/uVpk1gf2MAiu0xTjSmGXZJNx/96yDIe90OlKDNYU6MZSfRrBxQRHWH q/Vn5DglokPEXbS32KTg71ASMeDyrnh+z3unUJGglg3wtaev6s9o8cpVtcLSJuh9 /myvg3PldHMqqMudH8IXZv89NyqxW/ySO1QdtDCE5pb7ZeYaa2Y= =mMxZ -----END PGP SIGNATURE----- --mTAnpWVoLNHHGNT2--