Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: felix Newsgroups: gnu.bash.bug Subject: Re: Undocumented feature: Unnamed fifo '<(:)' Date: Sun, 28 Jun 2020 18:35:59 +0200 Lines: 48 Approved: bug-bash@gnu.org Message-ID: References: <20200628134945.GB24863@medium.hauri> <20200628163559.GA3718@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 1593362350 27635 209.51.188.17 (28 Jun 2020 16:39:10 GMT) X-Complaints-To: action@cs.stanford.edu To: Dennis Williamson Envelope-to: bug-bash@gnu.org Resent-From: felix Resent-Date: Sun, 28 Jun 2020 18:38:59 +0200 Resent-Message-ID: <20200628163859.GB3718@medium.hauri> Resent-To: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: 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 12:39:03 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: <20200628163559.GA3718@medium.hauri> X-Mailman-Original-References: <20200628134945.GB24863@medium.hauri> Xref: csiph.com gnu.bash.bug:16470 In order to prevent ressource eating, once `date -f - +%s` runned as background, date_to_epoch will become: $ exec 8<> <(:) $ exec 9> >(exec stdbuf -o0 date -f - +%s >&8 2>&8) $ date_to_epoch() { echo >&9 ${@:2} read -t 1 -u 8 ${1:-answeredEpoch} } $ date_to_epoch _out 2009-02-13 23:31:30 UTC $ echo $_out 1234567890 U could test my demo script at https://f-hauri.ch/vrac/date1fork-demo.sh.txt or check for my `shell_connector' at https://f-hauri.ch/vrac/shell_connector.sh.txt This is not only interesting for `date`! I use them with `bc`, `tput`, and lot of other applications, upto `sqlite`, `mysql` and `postgresql` with ability of playing with temporary tables and other session related stuff... On Sun, Jun 28, 2020 at 10:55:59AM -0500, Dennis Williamson wrote: > date_to_epoch () { > date -d "$1" +%s > } > > _out=$(date_to_epoch "$_string") > On Sun, Jun 28, 2020, 8:50 AM felix wrote: > > ... > > _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 -- Félix Hauri - - http://www.f-hauri.ch