gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 12:51:07 34 4
gpt4 key购买 nike

我正在尝试配置我的 windows 可移植 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-)

关于windows - 如何在 Windows git bash shell 中访问此环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20288985/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com