我正在尝试配置我的
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记忆棒上,驱动器号码当然会随时改变.@H_404_4@
我试过回声:@H_404_4@
$PAL:DRIVELETTER ${PAL:DRIVELETTER}
还有很多其他的东西.@H_404_4@
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.@H_404_4@
所以你的变量名PAL:DRIVELETTER实际上是无效的.
您需要从’env’输出中提取它,如proposed in this answer:@H_404_4@
pal_driveletter=$(env |grep "^PAL:DRIVELETTER=" | cut -d= -f2-)