FreeLightman
FreeLightman

Reputation: 2304

Why exporting env var in bash script does not affect env?

I want to set env variable in shell script. Shell script content is:

#!/bin/bash
export XDEBUG_CONFIG="idekey=PHPSTORM"

I tried both bash bin/enable_debug and bin/enable_debug. After both command I get:

$ echo $XDEBUG_CONFIG

$

However if I run export XDEBUG_CONFIG="idekey=PHPSTORM" directly in cli it works. What's wrong with my method?

Upvotes: 1

Views: 907

Answers (1)

Naveen Hiremath
Naveen Hiremath

Reputation: 351

You can try running your script as below:

. bin/enable_debug

OR

source bin/enable_debug

as indicated by @Aserre

Upvotes: 1

Related Questions