help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there a way to get the output of a function without an extra bash pro


From: Peng Yu
Subject: Is there a way to get the output of a function without an extra bash process?
Date: Sun, 10 May 2020 16:20:42 -0500

Hi,

$(fun) by default will always use a new bash process. This is wasteful
in certain cases. In there a way to use the existing bash process
(without using a temp file)? Thanks.

$ cat ./main2.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

set -v
echo "$BASHPID"
function f {
        echo "$BASHPID"
}
echo "$(f)"
$ ./main2.sh
echo "$BASHPID"
32056
function f {
        echo "$BASHPID"
}
echo "$(f)"
32057

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]