Can I export a variable to the environment from a bash script without sourcing it?

前端 未结 7 1759
半阙折子戏
半阙折子戏 2020-11-22 05:51

Suppose that I have this script

export.bash:

#! /usr/bin/env bash
export VAR=\"HELLO, VARIABLE\"

When I execute th

7条回答
  •  执念已碎
    2020-11-22 06:34

    Execute

    set -o allexport
    

    Any variables you source from a file after this will be exported in your shell.

    source conf-file
    

    When you're done execute. This will disable allexport mode.

    set +o allexport
    

提交回复
热议问题