If I write a Scala script (or App) that just prints out the command line arguments, I notice that it ignores all the '!' characters. For example, if my script looks like:
println(args(0))
And I run it with:
scala MyScript "Hello!"
I get the output:
Hello
And if I run it with:
scala MyScript "Hello! World!"
I also get:
Hello
What's going on? What is the purpose of the ! character in arguments that causes this behaviour?
!
is history substitution.Try
scala MyScript hello!
with!
at EOL to see it work as if quoted.http://www.gnu.org/software/bash/manual/bashref.html#Event-Designators
http://www.gnu.org/software/bash/manual/bashref.html#Single-Quotes
On windows, the
"scala.bat"
command script has delayed expansion enabled.http://en.wikibooks.org/wiki/Windows_Batch_Scripting
http://en.wikibooks.org/wiki/Windows_Batch_Scripting#SETLOCAL
http://en.wikibooks.org/wiki/Windows_Batch_Scripting#Command-line_arguments
To disable interpretation of
!myvar!
: