Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

295
Visualizações
What happens if the interpreter specified after #! is not available?

What happens if the interpreter specified after #! is not available?

I know that after the shebang I have to specify the interpreter (best practice is /bin/bash). As a beginner I don't dare to try a lot I am afraid to damage my system.

Could you give me examples of screenshots of the two scenarios:

  • the interpreter exists
  • the interpreter is not available

I just want to understand.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

try a lot I am afraid to damage my system.

Don't worry - it's safe here. Programmers make typos all the time.

the interpreter exists

For example, a file named thefile contains the following:

#!/bin/cat
blabla

Then, when the file has executable permission bit set, then executing the file itself will execute the program /bin/cat with one argument ./thefile, as if you would type /bin/cat ./thefile in your shell. Program cat just prints the content of the file, so when exeucting ./thefile will execute /bin/cat ./thefile with will print the file content to the screen.

$ ./thefile 
#!/bin/cat
blabla

the interpreter is not available

What happens if the interpreter specified after #! is not available?

If the shebang happens to be interpreted by your shell, it would be expected that your shell will then print some kind of an information message that it can't find the interpreter, with some error description that "this file does not exist" or similar. If the file is run via one of exec*() system calls, then the kernel will return with ENOEXEC error code (per source code here)

Let's take a file named anotherfile with the following content:

#!fdsafdsafafdasfdas
blabla

For example, Bash shell will try to parse #! line by itself. Bash interactive shell would print:

$ ./anotherfile 
bash: ./anotherfile: fdsafdsafafdasfdas: bad interpreter: No such file or directory

But, for example, Busybox's Ash shell presents a different message:

$ ./anotherfile 
/bin/sh: ./anotherfile: not found

Also https://en.wikipedia.org/wiki/Shebang_(Unix) might be interesting.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda