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

前端 未结 7 1761
半阙折子戏
半阙折子戏 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:47

    The answer is no, but for me I did the following

    the script: myExport

    #! \bin\bash
    export $1
    

    an alias in my .bashrc

    alias myExport='source myExport' 
    

    Still you source it, but maybe in this way it is more useable and it is interesting for someone else.

提交回复
热议问题