[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Examples of concurrent coproc usage?
From: |
Zachary Santer |
Subject: |
Re: Examples of concurrent coproc usage? |
Date: |
Tue, 16 Apr 2024 08:45:11 -0400 |
On Tue, Apr 16, 2024 at 3:56 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Apr 16 2024, Carl Edquist wrote:
>
> > Well, you _can_ shovel binary data too: (*)
> >
> > while IFS= read -rd '' X; do printf '%s\0' "$X"; done
> >
> > and use that pattern to make a shell-only version of tee(1) (and I suppose
> > paste(1)). Binary data doesn't work if you're reading newline-terminated
> > records, because you cannot store the NUL character in a shell
> > variable. But you can delimit your records on NULs, and use printf to
> > reproduce them.
>
> Though that will likely add a spurious null at EOF.
Just wouldn't copy over whatever might have followed the final null
byte, if we're not talking about null-terminated data.
printf_format='%s\x00'
while
IFS='' read -r -d '' X ||
{
[[ -n ${X} ]] &&
{
printf_format='%s'
true
}
#
}
#
do
printf -- "${printf_format}" "${X}"
done
Might've gotten lucky with all those .so files ending in a null byte
for whatever reason.
There's no way to force this to give you the equivalent of sized
buffers. 'read -N' obviously has the same problem of trying to store
the null character in a variable. So, if you're trying to run this on
a huge text file, you're going to end up trying to shove that entire
file into a variable.
- Re: Examples of concurrent coproc usage?, (continued)
- Re: Examples of concurrent coproc usage?, felix, 2024/04/17
- Re: Examples of concurrent coproc usage?, Chet Ramey, 2024/04/03
- Re: Examples of concurrent coproc usage?, Zachary Santer, 2024/04/03
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Re: Examples of concurrent coproc usage?, Zachary Santer, 2024/04/15
- Re: Examples of concurrent coproc usage?, Carl Edquist, 2024/04/16
- Re: Examples of concurrent coproc usage?, Andreas Schwab, 2024/04/16
- Re: Examples of concurrent coproc usage?,
Zachary Santer <=
- Re: Examples of concurrent coproc usage?, Carl Edquist, 2024/04/16
- Re: Examples of concurrent coproc usage?, Chet Ramey, 2024/04/17
- Re: Examples of concurrent coproc usage?, Martin D Kealey, 2024/04/17
- Re: Examples of concurrent coproc usage?, Chet Ramey, 2024/04/19
- Re: Examples of concurrent coproc usage?, Martin D Kealey, 2024/04/21
- Re: Examples of concurrent coproc usage?, Chet Ramey, 2024/04/22
- Re: Examples of concurrent coproc usage?, Carl Edquist, 2024/04/20
- Re: Examples of concurrent coproc usage?, Martin D Kealey, 2024/04/21
- Re: Examples of concurrent coproc usage?, Carl Edquist, 2024/04/21
- Re: Examples of concurrent coproc usage?, Martin D Kealey, 2024/04/22