I am trying to create a command line based on the transfer in the "-e" flag, and another variable to another script base, calling as a subroutine, and ran into some strange problem; I lose the "-e" part of the line when I pass it to the subroutine. I am creating a couple of examples illustrating the problem, any help?
This works as you expected:
$echo "-e $HOSTNAME" -e ops-wfm
Is not; we lose "-e" because it is interpreted as a special classifier.
$myFlag="-e $HOSTNAME"; echo $myFlag ops-wfm
Adding the character "\" escape also does not work, I get the correct line with "\" in front:
$myFlag="\-e $HOSTNAME"; echo $myFlag \-e ops-wfm
How to prevent swallowing -e ?
source share