I'm setting variable $hack
which I wish to expand and insert after the first line in a text file. The first line contains this text: project(libpyside)
Tried this:
$ sed -i "s|project(libpyside)|project(libpyside)\n$hack|" CMakeLists.txt
sed: -e expression #1, char 124: unterminated `s' command
...and this:
$ sed -i "/project(libpyside)/ r $hack" CMakeLists.txt
sed: -e expression #1, char 222: unknown option to `s'
...and this:
$ sed -i -e "2i${hack}" CMakeLists.txt
sed: -e expression #1, char 201: unknown option to `s'
This is my $hack
variable:
hack='#HACK: CMake with broken Qt5Qml_PRIVATE_INCLUDE_DIRS, Qt5Quick_PRIVATE_INCLUDE_DIRS
if(${Qt5Qml_FOUND})
if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS)
endif()
endif()
if(${Qt5Quick_FOUND})
if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme})
list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS)
endif()
endif()'
What am I doing wrong?
The reason I'm not putting this into a file is I'm doing all of this from within a Dockerfile.