如何在windows git bash shell中访问此环境变量

前端之家收集整理的这篇文章主要介绍了如何在windows git bash shell中访问此环境变量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试配置我的 windows mobile git bash shell.当我执行env时,我得到:
ANT_HOME=C:\Program Files\WinAnt
PORTABLEAPPS.COMVIDEOS:FORWARDSLASH=H:/Documents/Videos
VBox_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
PORTABLEAPPS.COMLOCALEWINNAME=LANG_ENGLISH
PAL:LASTPORTABLEAPPSBASEDIR:DOUBLEBACKSLASH=H:
PAL:DRIVELETTER=H   **** this is the variable I am after  ******
PAL:APPDIR=H:\PortableApps\GitPortable\App
TEMP=/tmp

我试图引用的变量是PAL:DRIVELETTER = H.我想在我的.bash_profile脚本中使用这个设置我的路径.这一切都在USB记忆棒上,驱动器号码当然会随时改变.

我试过回声:

$PAL:DRIVELETTER
${PAL:DRIVELETTER}

还有很多其他的东西.

The bash “Definitions”确实明确提到:
name

A word consisting solely of letters,numbers,and underscores,and beginning with a letter or underscore.
Names are used as shell variable and function names.
Also referred to as an identifier.

所以你的变量名PAL:DRIVELETTER实际上是无效的.
您需要从’env’输出提取它,如proposed in this answer

pal_driveletter=$(env |grep "^PAL:DRIVELETTER=" | cut -d= -f2-)
原文链接:https://www.f2er.com/windows/365211.html

猜你在找的Windows相关文章