I have a variable $MOH in Bash which may contain words beginning with minus (-).
I don't want echo to interpret these words as parameters.
For most commands I do it like this:
cmd -- $MOH
But echo does not support --.
So I get a problem in this example:
MOH=-n
echo $MOH
Echo thinks -n is a parameter. But as I said I want to echo the variable as it is. (Please note that the value of $MOH is not known to me.)
So my question is: How to escape a variable for use in echo?
Also the escape function should be aware of future parameters in echo which are not known yet.
Edit: Thank you for editing. The question was already asked and the solution is to use printf instead of echo.