Arijit Roy
Arijit Roy

Reputation: 399

Not able to set a variable to a path

am new in writing shell script. When I execute the following program every time I get "$userInput1=/home/xyx/dest1: No such file or directory"

fun1()
{
    .
    .
    $2=$userInputPath'/*' #$userInputPath holds a path like /home/xyx/dest1 
    .
    .
}

Am using Bourne shell and calling the function like the following manner -

fun1 $input1 userInput1

and after calling the function if I echo $userInput1 it prints nothing. It is to be mentioned that the path /home/xyx/dest1 is valid.

Upvotes: 1

Views: 32

Answers (1)

Zombo
Zombo

Reputation: 1

Well normally you would use declare but it is inside a function. So if you want access to userInput1 outside of the function you will need to do

fun1 () {
  read $2 <<< "$userInputPath/*"
}

Upvotes: 1

Related Questions