简体   繁体   中英

How do I access this environment variable in the windows git bash shell

I am trying to configure my windows portable git bash shell . When I execute env I get:

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

The variable I am trying to reference is PAL:DRIVELETTER=H . I want to use this set my path in my .bash_profile script. This is all on a USB stick and the drive letter will of course change from time to time.

I have tried echoing:

$PAL:DRIVELETTER
${PAL:DRIVELETTER}

and numerous other things.

The bash "Definitions" does mention explicitly:

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.

So your variable name PAL:DRIVELETTER is actually invalid.
You need to extract it from the ' env ' output, as proposed in this answer :

pal_driveletter=$(env |grep "^PAL:DRIVELETTER=" | cut -d= -f2-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM