Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash redirecting EOF into variable [duplicate]

this is my file perl5lib.sh:

export PERL5LIB=`cat |tr '\n' ':'`<<EOF
/home/vul/repository/projects/implatform/daemon/trunk/lib/
/home/vul/repository/projects/platformlib/tool/trunk/cpan_lib
/home/projects/libtrololo

I want to start file as

. perl5lib.sh

to populate PERL5LIB variable, but it hangs. What is wrong? my goal is to left folder names at the end of file, so I can add new simply:

echo dirname >> myscript

I have tried and export PERL5LIB=$(echo blabla) and cat<<EOF both work separately, but not together.

=================== THE SOLUTION ============================

function do the trick!

function fun
{
     export PERL5LIB=`cat|tr '\n' ':'`
}
fun<<EOF
/dir1/lib
/dir2/lib
/dir3/lib
EOF
like image 427
xoid Avatar asked Jun 21 '26 08:06

xoid


1 Answers

cat is useless here. Provide EOF inside the subshell:

#! /bin/bash
export PERL5LIB=$(tr '\n' ':'<<EOF
/home/vul/repository/projects/implatform/daemon/trunk/lib/
/home/vul/repository/projects/platformlib/tool/trunk/cpan_lib
/home/projects/libtrololo
EOF
)
like image 79
choroba Avatar answered Jun 23 '26 04:06

choroba