【问题标题】:What alternatives are there for " readlink -e"“ readlink -e”有什么替代品
【发布时间】:2019-12-03 08:21:45
【问题描述】:

我使用一个生成文件,它为了创建一个库使用一个看起来像这样的 .pc 文件

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

问题是在 mac 上 -e 标志不起作用(即使我安装了 coreutils)。有没有办法更换flag?

【问题讨论】:

  • GNU make 有 $(realpath .)
  • 谢谢,我应该如何将它包含在脚本中:“current_path=$(realpath .)”?
  • current_path:=$(realpath .) 更好,因为 realpath 可能实际读取磁盘驱动器。
  • 这不是Makefile代码; make 如何调用它?您可以在调用中添加参数吗?

标签: macos makefile readlink


【解决方案1】:

我能找到的最便携的方式:

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

在你的情况下:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 2022-11-10
    • 2012-02-05
    • 1970-01-01
    相关资源
    最近更新 更多