I have a bash command that requires a string value after "-v". When this string value has a leading "-", bash tries to interpret it as a new option of the bash command rather than the value I'm trying to give for -v. Is there a way I can escape this leading hyphen? I tried
-v -- -myValue
but then it tells me "option '-v' needs a parameter."
The command is calling a ruby file. I think this is the meaningful part of the ruby code for the purposes of this question:
opts = Trollop::options do
opt :method, "Encrypt or Decrypt", :short => "m", :type => :string, :default => "decrypt"
opt :value, "Value to Decrypt or Encrypt", :short => "v", :type => :string, :default => ""
end
There's two conventional ways to specify arguments, but these are not enforced at the shell level, they're just tradition:
-v xxxx
--value=xxxx
Now it's sometimes possible to do:
-vxxxx
If you have a value with a dash and it's not being interpreted correctly, do this:
--value=-value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With