What alternatives are there for “ readlink -e”

那年仲夏 提交于 2021-02-11 14:44:14

问题


I use a makefile which in order to create a library uses a .pc file which looks like this

current_path=`readlink -e .`
cat > lib/libmy.pc << EOM
prefix=$current_path
includedir=\${prefix}/inc
libdir=\${prefix}/lib

Name: my
Description: My library
Version: 1.0
Cflags: -I\${includedir}
Libs: -L\${libdir} -lmy
Libs.private: -lm
EOM

The problem is that on mac the -e flag doesn't work (even I installed coreutils). I there a method to replace the flag?


回答1:


The most portable way I could find:

current_path=`python -c "import os; print(os.path.abspath('${MY_AWESOME_PATH}'))"`

in your case:

current_path=`python -c "import os; print(os.path.abspath('.'))"`


来源:https://stackoverflow.com/questions/57195470/what-alternatives-are-there-for-readlink-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!