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


Groups > gnu.bash.bug > #16467

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

From Dennis Williamson <dennistwilliamson@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Undocumented feature: Unnamed fifo '<(:)'
Date 2020-06-28 10:55 -0500
Message-ID <mailman.559.1593359779.2574.bug-bash@gnu.org> (permalink)
References <20200628134945.GB24863@medium.hauri> <CANaoh6KSJS8X73Zqj7M8TT6_gAOjGraZx1EaEVwUNN_=Yya3wQ@mail.gmail.com>

Show all headers | View raw


On Sun, Jun 28, 2020, 8:50 AM felix <felix@f-hauri.ch> wrote:

>
>    _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
>
>


How is running your

        echo >&9 $_string
        read -t 1 -u 8 _out

many times better than running your

   _out=$(date -d "$_string" +%s)

many times?

Why don't you just use a function?

date_to_epoch () {
    date -d "$1" +%s
}

_out=$(date_to_epoch "$_string")

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Undocumented feature: Unnamed fifo '<(:)' Dennis Williamson <dennistwilliamson@gmail.com> - 2020-06-28 10:55 -0500

csiph-web