I've got a shell script that gets called with arguments that contain variable names. I want the variable to be replaced with their values. Consider the example below: It solves my problem, but it uses eval. I want to avoid eval for security reasons.
#!/bin/bash
#
# example:
# $> replace.sh arg '$VAR'
# arg value
VAR=value
ARGS=$(eval echo $*)
echo $ARGS