Example:
#!/bin/bash
source "$VARIABLE"
Is to retrieve values from a remote location using curl.
http://example.com/file.cnfg
Example:
#!/bin/bash
source "$VARIABLE"
Is to retrieve values from a remote location using curl.
http://example.com/file.cnfg
You don't need or want a variable. The common way to do this is
curl http://example.com/file.cnfg | sh
If you really genuinely need to execute the code in the current shell,
source <(curl http://example.com/file.cnfg)
does that.
Caveats about security implications cannot be overstated. You need to understand what could go wrong if the server is malicious, hijacked, misconfigured, down, or just in a really grumpy mood.
You should be asking yourself "can I avoid using a variable" (and also, "can I avoid spawning an external process") and if the answer is yes, that's usually what you should do.
Executing downloads blindly is definitely not something you want to do casually.
You can execute the contents of a variable using eval
, as in:
eval "$variable"
That's not something you want to do without thinking through the security implications either.