Shebang

Shebang

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 el mismo (el SheBang más habitual suele ser "#!/bin/bash", que es una llamada al intérprete de comandos Bash). Este método estándar,[1] permite que el usuario pueda ejecutar un programa interpretado igual a como ejecutaría un programa binario.

Cuando no se conoce la ruta absoluta del mismo, es posible utilizar el programa auxiliar env,[2] que generalmente suele estar en /usr/bin.[3] Éste es un método muy usado para scripts donde el intérprete no tiene la misma ruta en todos los sistemas (por ejemplo, el SheBang usado generalmente para python es "#!/usr/bin/env python", que es una llamada a env).

Sirve también para identificar el formato de fichero a modo de Número Mágico.

En algunos sistemas es posible especificar en el shebang hasta un único parámetro después del nombre del programa a ejecutar, linux por ejemplo, mientras que en otros como por ejemplo Mac OS X es posible especificar varios, al separarlos por espacios.[3]

Este parámetro es necesario en algunos casos, como en scripts hechos AWK, ya que para indicar cuál es el script que tiene que cargar, se utiliza el parámetro -f.

Ejemplo

Al crear un archivo de texto con permisos de ejecución llamado programa, con el siguiente contenido:

#!/usr/bin/awk -f
BEGIN {
  print "parámetros:"
  for (i = 1; i < ARGC; i++)
    print "  " i ": " ARGV[i]
}

Cuando se ejecute: ./programa argumento1 argumento2, el sistema operativo, tras leer la línea del shebang, procederá de hecho a ejecutar: /usr/bin/awk -f ./programa argumento1 argumento2. Obteniéndose como resultado:

parámetros:
  1: argumento1
  2: argumento2

Referencias

  1. The Open Group. «Base WG Resolution - #! executable scripts» (en inglés). Consultado el 28 de noviembre de 2010.
  2. The IEEE and The Open Group. «Especificación de env» (en inglés). Consultado el 28 de noviembre de 2010.
  3. a b Sven Mascheck. «The #! magic, details about the shebang» (en inglés). Consultado el 28 de noviembre de 2010.

Enlaces externos


Wikimedia foundation. 2010.

Игры ⚽ Нужен реферат?

Mira otros diccionarios:

  • 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 — 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 — 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  …   Wikipédia en Français

  • 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

Compartir el artículo y extractos

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