GNU bug report logs -
#6379
process substitution with a give suffix
Previous Next
Reported by: Peng Yu <pengyu.ut <at> gmail.com>
Date: Tue, 8 Jun 2010 18:34:02 UTC
Severity: normal
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6379 in the body.
You can then email your comments to 6379 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6379
; Package
coreutils
.
(Tue, 08 Jun 2010 18:34:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Peng Yu <pengyu.ut <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Tue, 08 Jun 2010 18:34:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
On Tue, Jun 8, 2010 at 1:02 PM, Greg Wooledge <wooledg <at> eeg.ccf.org> wrote:
> On Tue, Jun 08, 2010 at 12:53:47PM -0500, Peng Yu wrote:
>> I have a program that only accept argument with a give suffix
>>
>> ./program xxx.suffix
>>
>> If I use process substitution, which gives me /dev/fd/xx, it will not
>> work with the program. Is there a way to make sure a suffix is added
>> to the substitute process file handle in /def/fd/, so that the program
>> can work with process substitution?
>
> mkfifo myfifo.suffix
> something >myfifo.suffix &
> ./program <myfifo.suffix
> wait
> rm myfifo.suffix
The above question was sent to bug-bash. But since it is related to
mkfilo. I redirect it to bug-coreutils.
I have more than one arguments. I tried the following code. It doesn't
seem to work for more than one arguments. Would you please let me know
what is wrong?
BTW, using fifo is going to be much faster than using a temp file as
it avoid the disk usage, right?
$ cat a.txt
In a.txt
$ cat b.txt
In b.txt
$ cat main.sh
#!/usr/bin/env bash
mkfifo a.suffix
cat a.txt >a.suffix &
mkfifo b.suffix
cat b.txt >b.suffix &
cat <a.suffix <b.suffix
wait
rm a.suffix b.suffix
$ ./main.sh
In b.txt
--
Regards,
Peng
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6379
; Package
coreutils
.
(Tue, 08 Jun 2010 19:15:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 6379 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 06/08/2010 12:33 PM, Peng Yu wrote:
>> mkfifo myfifo.suffix
>> something >myfifo.suffix &
>> ./program <myfifo.suffix
>> wait
>> rm myfifo.suffix
>
> The above question was sent to bug-bash. But since it is related to
> mkfilo. I redirect it to bug-coreutils.
Your question is about how to use various Unix tools together; rather
than directing to bug-bash or bug-coreutils, you may be better off
directing to a generic shell-programming forum.
As it is, you didn't raise any bug report about the mkfifo program, so
redirecting to coreutils didn't really buy you anything.
>
> I have more than one arguments. I tried the following code. It doesn't
> seem to work for more than one arguments. Would you please let me know
> what is wrong?
>
> BTW, using fifo is going to be much faster than using a temp file as
> it avoid the disk usage, right?
A fifo will have the same speed as a pipe (another name for a fifo is
named pipe; unlike 'foo | bar', where the pipe is anonymous and exists
between exactly two processes, a fifo can be accessed from the file
system by multiple processes, but but under the hood, it uses the same
kernel pipe handling code). It has the drawback of being non-seekable
in comparison to temporary regular files. It has the advantage of
atomic operations not guaranteed by disk files, provided you stick to
transactions below the size guaranteed by your kernel. And if you use a
ramdisk backing store for /tmp, there is little difference in speed
(either way, a ramdisk or a fifo does not have to do disk I/O); but
since you can't guarantee that /tmp is a ramdisk, yes, a fifo can be
faster for interprocess communication. And if used incorrectly, it has
the potential to deadlock your shell script (something that won't happen
with regular files).
>
> $ cat a.txt
> In a.txt
> $ cat b.txt
> In b.txt
> $ cat main.sh
> #!/usr/bin/env bash
>
> mkfifo a.suffix
> cat a.txt >a.suffix &
> mkfifo b.suffix
> cat b.txt >b.suffix &
> cat <a.suffix <b.suffix
This is redirecting stdin twice, with the net effect that cat only sees
the contents of the fifo b.suffix. You probably meant to do:
cat a.suffix b.suffix
> wait
> rm a.suffix b.suffix
> $ ./main.sh
> In b.txt
>
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
bug closed, send any further explanations to
6379 <at> debbugs.gnu.org and Peng Yu <pengyu.ut <at> gmail.com>
Request was from
Jim Meyering <jim <at> meyering.net>
to
control <at> debbugs.gnu.org
.
(Mon, 25 Jul 2011 15:20:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 23 Aug 2011 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.