Shebang

Shebang

Le shebang, représenté par #!, est un en-tête d'un fichier qui indique au système que ce fichier est un ensemble de commandes pour l'interpréteur indiqué, possiblement un mot-valise pour sharp-bang[1].

On trouve aussi d'autres dénominations : sha-bang, shabang, she-bang, hash-bang.

Techniquement, les caractères #! sont en fait un « nombre magique » (magic number), composé de deux octets, un marqueur spécial qui désigne un type de fichier, ou un script shell exécutable (la commande man magic donne plus de détails sur ce thème).

Tout de suite après le shebang se trouve un chemin (exemple : #!/bin/bash). C'est le chemin vers le programme qui interprète les commandes de ce script, qu'il soit un shell, un langage de script, un langage de programmation ou un utilitaire. On peut le faire suivre des options qu'il reconnaît (par exemple -x pour un shell pour afficher le détail de son exécution). Ensuite, cet interpréteur de commandes exécute les commandes du script, en commençant au début (ligne 1), en ignorant les commentaires.

Exemples de shebang :

#!/bin/sh -x
#!/bin/bash
#!/usr/bin/perl
#!/usr/bin/tcl
#!/bin/sed -f
#!/usr/awk -f

Le shebang est utilisé dans les fichiers texte de scripts dans les environnements de type UNIX (GNU/Linux, BSD, etc).

On peut utiliser le programme env au lieu d'un interpréteur de commandes pour chercher celui-ci dans le PATH (ce qui évite de devoir réécrire la première ligne des scripts si on doit les porter sur une autre machine par exemple) :

#!/usr/bin/env python

...mais le problème est que l'on risque de ne pas appeler la bonne version de l'interpréteur si plusieurs sont présentes sur la machine.

Notes et références

  1. (en) shebang

Wikimedia Foundation. 2010.

Contenu soumis à la licence CC-BY-SA. Source : Article Shebang de Wikipédia en français (auteurs)

Игры ⚽ Нужно сделать НИР?

Regardez d'autres dictionnaires:

  • Shebang! — is an all female breakdance crew in Toronto, Ontario, Canada. The group is comprised of b girls with the stage names Blazin , jennrock, mae hem, Ms. Mighty, and DJ Dalia.shebang! has performed with notable artists including the Beastie Boys,… …   Wikipedia

  • Shebang — is a slang term for the matter at hand, as in the phrase, the whole shebang . The word is also slang for a party, gathering or event, such as I m throwing a little shebang at the barn tonight . The word can also refer to:* Shebang (Unix), the #!… …   Wikipedia

  • Shebang — es, en la jerga de Unix, el nombre que recibe el par de caracteres #! que se encuentran al inicio de los programas ejecutables interpretados. A continuación de estos caracteres se indica la ruta completa al intérprete de las órdenes contenidas en …   Wikipedia Español

  • shebang — 1862, hut, shed, shelter, perhaps an alteration of SHEBEEN (Cf. shebeen) (q.v.). Phrase the whole shebang first recorded 1869, but relation to the earlier use of the word is obscure. Either or both senses may also be mangled pronunciations of Fr …   Etymology dictionary

  • shebang — ► NOUN informal ▪ a matter, operation, or situation: the whole shebang. ORIGIN originally US, in the sense «a rough hut or shelter»; of unknown origin …   English terms dictionary

  • shebang — ☆ shebang [shə baŋ′ ] n. [prob. var. of SHEBEEN] 1. a shack or hut 2. Informal an affair, business, contrivance, thing, etc.: chiefly in the whole shebang …   English World dictionary

  • Shebang — She*bang , n. [Cf. {Shebeen}.] A jocosely depreciative name for a dwelling or shop. [Slang,U.S.] [1913 Webster] …   The Collaborative International Dictionary of English

  • Shebang — Die Shebang Zeichen – hash bang Shebang (auch Magic Line) bezeichnet bei unixoiden Betriebssystemen die Zeichenkombination #! am Anfang eines Skriptprogramms. Die Markierung führt dazu, dass das folgende Kommando mitsamt allen angegebenen… …   Deutsch Wikipedia

  • shebang — /ʃəˈbæŋ / (say shuh bang) Colloquial –noun 1. a thing; affair; business. 2. a disturbance; brawl. –phrase 3. the whole shebang, the totality of something; the lot; everything: *So I m going to give em a picnic, see? The whole shebang. –ruth park …  

  • shebang — noun a) Any matter of present concern; thing; or business. Before Id share anything with you, he said bitterly, Id lose the whole shebang. b) A lean to or temporary shelter. <! [sic] all in one paragraph […] So they got into the empty omnibus… …   Wiktionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”