这在 Renviron 中意味着什么?
what does this mean in Renviron?
我在我的 Renviron 文件中看到很多东西,例如
MAKE=${MAKE-'make'}
## Prefer a POSIX-compliant sed on e.g. Solaris
SED=${SED-'/usr/bin/sed'}
## Prefer a tar that can automagically read compressed archives
TAR=${TAR-'/usr/bin/tar'}
## System and compiler types.
R_SYSTEM_ABI='macos,gcc,gxx,gfortran,gfortran'
## Strip shared objects and static libraries.
R_STRIP_SHARED_LIB=${R_STRIP_SHARED_LIB-'strip -x'}
R_STRIP_STATIC_LIB=${R_STRIP_STATIC_LIB-'strip -S'}
R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'}
我很困惑。为什么我们写 R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'}
而不是 R_LIBS_USER='~/R/aarch64-apple-darwin20-library/4.1'
?前者到底是什么意思?
这是 POSIX shell 变量扩展的一个例子。如果设置模式 ${variable-default}
将扩展为 variable
中的值,否则将扩展为 default
中的值。 ?Startup
帮助页面对此进行了描述。
因此您可以设置一个名为 R_LIBS_USER
的环境变量来使用您自己的自定义库,否则 R 将使用 ~/R/aarch64-apple-darwin20-library/4.1
,其他变量也类似。
我在我的 Renviron 文件中看到很多东西,例如
MAKE=${MAKE-'make'}
## Prefer a POSIX-compliant sed on e.g. Solaris
SED=${SED-'/usr/bin/sed'}
## Prefer a tar that can automagically read compressed archives
TAR=${TAR-'/usr/bin/tar'}
## System and compiler types.
R_SYSTEM_ABI='macos,gcc,gxx,gfortran,gfortran'
## Strip shared objects and static libraries.
R_STRIP_SHARED_LIB=${R_STRIP_SHARED_LIB-'strip -x'}
R_STRIP_STATIC_LIB=${R_STRIP_STATIC_LIB-'strip -S'}
R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'}
我很困惑。为什么我们写 R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'}
而不是 R_LIBS_USER='~/R/aarch64-apple-darwin20-library/4.1'
?前者到底是什么意思?
这是 POSIX shell 变量扩展的一个例子。如果设置模式 ${variable-default}
将扩展为 variable
中的值,否则将扩展为 default
中的值。 ?Startup
帮助页面对此进行了描述。
因此您可以设置一个名为 R_LIBS_USER
的环境变量来使用您自己的自定义库,否则 R 将使用 ~/R/aarch64-apple-darwin20-library/4.1
,其他变量也类似。