0

I am running a very simple bash script on Macosx Yosemite

#!/bin/bash
makefilePath=$(echo $(pwd)/make.sh | sed 's/ /\\ /')
echo $makefilePath
source "$makefilePath"

The first three lines work as expected, but the fourth line creates a returns an error No such file or directory, even though if I run the command from makefile directly in the shell by copy pasting it, it works fine.

I don't know what the problem is. Please help.

1 Answers1

3

You didn't write what it is your actual PWD, but I assume it contain a space, so the sed command will mangle the filename, and it will no more represent the original file.

The mangled filename is interpreted literally by shell expansion (and with double quotes). Note also '\\' will not do what you are probably want.