Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of !# (bang-pound) in a sh / Bash shell script?

I want to understand how this Scala script works:

#!/usr/bin/env bash
exec scala "$0" "$@"
!#
object HelloWorld {
    def main(args: Array[String]) {
        println("Hello, world! " + args.toList)
    }   
}
HelloWorld main args

On line 3, what is "!#" doing? Is the remainder of the file then fed to standard input of the Scala program? Also, is '!#' documented anywhere?

NB: The nearest thing I could find, although it is not directly relevant in any way is Stack Overflow question Why do you need to put #!/bin/bash at the beginning of a script file? (about the beginning of a Bash script).

like image 818
Jay Taylor Avatar asked Apr 08 '12 04:04

Jay Taylor


People also ask

What symbol means?

1. something used for or regarded as representing something else; a material object representing something, often something immaterial; emblem, token, or sign. 2. a letter, figure, or other character or mark or a combination of letters or the like used to designate something.

What is the meaning of :/?

What Does :/ Mean? :/ is an emoticon used to indicate indecision, skepticism, exasperation, and annoyance. The emoticon :/ is one of the most difficult to define. It can indicate a wide range of emotions, including (but not limited to) indecision, skepticism, exasperation, and annoyance.

What is the longest word in the world that takes 3 hours to say?

Methionylthreonylthreonylglutaminylarginyl… isoleucine is the chemical name for the protein of “titin” also known as “connectin.” The largest known protein that consists of 26, 926 amino acids is made up of 189, 819 letters and can take about three hours to pronounce.

What is the longest word in the dictionary?

Pneumonoultramicroscopicsilicovolcanoconiosis is the longest word entered in the most trusted English dictionaries.


1 Answers

From the original documentation:

Script files may have an optional header that is ignored if present. There are two ways to format the header: either beginning with #! and ending with !#, or beginning with ::#! and ending with ::!#.

So the following code is just a header for a Scala script:

#!/usr/bin/env bash
exec scala "$0" "$@"
!#
like image 66
BluesRockAddict Avatar answered Oct 12 '22 01:10

BluesRockAddict