1

if I need to unset an environment variable from script it used to be "sourced" like

. ./myscript.sh

or

source ./myscript.sh

But how do i make this work, if i launch this script from supervisord?

[program:myapp]
command=source /usr/bin/myscript.sh
...

does not work.

Simple example script (myscript.sh):

#!/bin/bash
unset -v SOME_VAR

That's all ...

David
  • 29
  • 1
  • 4

2 Answers2

2

You wouldn't generally /run/ a script by using source, instead you'd make it executable and then run it using it's path.

However, to specifically unset a variable just use unset:

$ TEST=foo
$ echo $TEST
foo
$ unset TEST
$ echo $TEST

$
shearn89
  • 3,403
  • 2
  • 15
  • 39
1

It works for me.

root@localhost:~# cat set.sh
hello1=world1
hello2=world2

root@localhost:~# cat unset.sh
unset hello1
unset hello2

root@localhost:~# . set.sh
root@localhost:~# env | grep ^hello
hello1=world1
hello2=world2
root@localhost:~# . unset.sh
root@localhost:~# env | grep ^hello
root@localhost:~#
jmnote
  • 11
  • 1