Want scripts using process replacement to work with Bash 3.1.20 without temporary files

Asked 2 years ago, Updated 2 years ago, 88 views

With Bash4, process replacement is available, for example:

$paste-d""<(echo "hoge")<(echo "piyo")
hogepiyo

However, process replacement is not available in Bash 3.1.20, so if you want to rewrite it straight, you have to use a temporary file.

$echo "hoge" > temp1
$ echo "piyo" > temp2
$ paste-d""temp1temp2
hogepiyo
$ rm temp1 temp2

I'd like to rewrite this to support Bash3 in a smarter way than not using temporary files.

(echo "hoge" echo "piyo" actually contains more complex commands, and its output includes line breaks.)

Bottom line:

It seems to be a msys-specific problem.

The msys2 (close to cygwin) bash I have worked, so if you can use it, I'll use it.

https://lists.gnu.org/archive/html/help-bash/2014-11/msg00046.html

moving:

$bash --version
GNU bash, version 4.3.30(5) - release(x86_64-pc-msys)
Copyright (C) 2013 Free Software Foundation, Inc.

not moving:

$bash --version
GNU bash, version 3.1.20(4) - release(i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.

bash

2022-09-30 16:11

2 Answers

I think process replacement can be used with Bash3.

$echo$BASH_VERSION
3.2.25(1) - Release
$ paste-d''<(echo hoge)<(echo piyo)
hogepiyo


2022-09-30 16:11

We have a bash introduction (O'REILLY) for bash-1.14, which also explains process replacement.I think Bash 3.1.20.

can handle it.


2022-09-30 16:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.