Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: felix Newsgroups: gnu.bash.bug Subject: Undocumented feature: Unnamed fifo '<(:)' Date: Sun, 28 Jun 2020 15:49:45 +0200 Lines: 53 Approved: bug-bash@gnu.org Message-ID: References: <20200628134945.GB24863@medium.hauri> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1593352198 19065 209.51.188.17 (28 Jun 2020 13:49:58 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: none client-ip=212.74.161.16; envelope-from=felix@f-hauri.ch; helo=smtp.f-hauri.ch X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/28 09:49:50 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20200628134945.GB24863@medium.hauri> Xref: csiph.com gnu.bash.bug:16466 Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security uname output: Linux medium 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Versions: 3.2.57(1)-release, 5.0.3(1)-release, 5.1.0(1)-alpha In order to reduce forks and make some tasks a lot quicker, I run forked filters as background tasks, with dedicated I/O fd. For sample, to convert human datetime to UNIX SECONDS, instead of running _out=$(date -d "$_string" +%s) many time in same script, I run something like: _fifo=$(mktemp -u /tmp/fifo-XXXXXXXX) mkfifo $_fifo exec 9> >(exec stdbuf -o0 date -f - +%s >$_fifo 2>&1) exec 8<$_fifo rm $_fifo Then to convert human datetime to UNIX SECONDS: echo >&9 $_string read -t 1 -u 8 _out become a lot quicker! But I recently discovered another way for this: exec 8<> <(:) exec 9> >(exec stdbuf -o0 date -f - +%s >&8 2>&8) usable in same way: echo >&9 $_string read -t 1 -u 8 _out maybe a little more quicker... This was tested using https://f-hauri.ch/vrac/date1fork-demo.sh under latest version of bash: 5.1.0(1), debian stable version: 5.0.3(1) and old 3.2: 3.2.57(1). There is maybe something to document or even create a new feature about open2 and open3... (I will have to rewrite https://f-hauri.ch/vrac/shell_connector.sh.txt ;) -- Félix Hauri - - http://www.f-hauri.ch