Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16470 > unrolled thread

Re: Undocumented feature: Unnamed fifo '<(:)'

Started byfelix <felix@f-hauri.ch>
First post2020-06-28 18:35 +0200
Last post2020-06-28 18:35 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Undocumented feature: Unnamed fifo '<(:)' felix <felix@f-hauri.ch> - 2020-06-28 18:35 +0200

#16470 — Re: Undocumented feature: Unnamed fifo '<(:)'

Fromfelix <felix@f-hauri.ch>
Date2020-06-28 18:35 +0200
SubjectRe: Undocumented feature: Unnamed fifo '<(:)'
Message-ID<mailman.563.1593362349.2574.bug-bash@gnu.org>
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 <felix@f-hauri.ch> 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  -  <felix@f-hauri.ch>  -  http://www.f-hauri.ch

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web