What does a hash key preceded by an exclamation key (!#)mean? [duplicate] - scala

This question already has answers here:
Why does Scala use a reversed shebang (!#) instead of just setting interpreter to scala
(3 answers)
Closed 7 years ago.
See the following script from scala tutorial, What does the !# mean?
#!/bin/sh
exec scala "$0" "$#"
!#
object HelloWorld extends App {
println("Hello, world!")
}
HelloWorld.main(args)

See: http://www.scala-lang.org/files/archive/nightly/docs-master/manual/html/scala.html
#! and !# mark script header. All content between those marks are ignored by scala interpreter. In that section you can put shell script which will launch the actual scala script.

The !# is called a "bangshe" (opposite of a "shebang"). It is a bit like a closing brace on the header statement.

Related

prompt not appearing after running `perl` [duplicate]

This question already has answers here:
How can I start an interactive console for Perl?
(24 answers)
Closed 1 year ago.
I have asked a similar question elsewhere but it eventually evolved into a series of comments. So once again, what package should I install to see the following prompt > after running perl but now not raku (all under Cygwin)?
EDIT
-l doesn't work either.
EDIT 2
Perl -d -e1 doesn't work for me either (Answer in comments as this question is closed):
You didn't provide the name of a program, and you didn't provide a program via the -e or -E command line options, so it's reading the program from STDIN.
perl does have a builtin debugger that you access by passing -d, but you still need to provide a program. (You can provide a trivial one using -e1.)
See How can I start an interactive console for Perl? for alternatives.

Scala: cannot load scala script with arguments

I am studying Scala and I am using Scala for win 10
I have write a script "helloarg.scala" with 1 line println("Hello, " + args(0) + "!")
When i used cmd to run file (not in scala shell), it worked.
C:\Users\Darkntnt>scala D:\Scala\helloarg.scala planet
Hello, planet!
However, It got the error when i load file from scala shell
Error:
scala> :load D:\Scala\helloarg.scala planet
usage: :load -v file
Please help me to fix this problem.
Thank you.
That's a good one.
:load doesn't respect args; there are a few different idioms for "run an app as a script".
I'll add this example to the issue about unifying them.
As a workaround, maybe val args = Array("planet") or similar.

Scala Execute Shell file [duplicate]

This question already has answers here:
Execute shell script from scala application
(2 answers)
Closed 5 years ago.
I have a .sh file in which I want to run in Scala once a Gatling scenario has finished.
Does anyone have any code that would execute my sh script.
You should use the after block provided by Gattling :-
Refer this : https://gatling.io/docs/current/general/simulation_structure/#hooks
Here you can use after block :-
after { println("Simulation is finished!")}
Rest all is pure scala so use #Andrey answer above

Why does Scala ignore exclamation points in command line arguments?

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!:
C:\Users\you> scala greeting.script "hello^!"
hello!
C:\Users\you> set world= Bob
C:\Users\you> scala greeting.script "hello!world!"
hello Bob

"sh -x" equivalent for Perl and Python scripts [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I make Perl and Python print each line of the program being executed?
I'm looking for an equivalent of sh -x for Perl and Python.
(Excerpted from Programming Perl’s chapter on the debugger.)
If your .perldb file contains:
parse_options("NonStop=1 LineInfo=tperl.out AutoTrace");
then your program will run without human intervention, putting trace
information into the file tperl.out. (If you interrupt it, you’d better
reset LineInfo to /dev/tty if you expect to see anything.)
Install Devel::Trace and perl -d:Trace.