Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two files, the first is 'ax':

#!/usr/bin/env zsh

print "Params: $*"
cat $*

And another one 'tst':

#! /home/me/ax

When I am in sh/csh/bash shell:

> ./tst
./tst: line 2: A: command not found
./tst: line 3: B: command not found
./tst: line 4: C: command not found

When I am in zsh shell:

Params: ./tst
#! /IW/users-home/e640846/ax

Is there a standard way to have the behavior I get in the zsh shell in other shell?

precision: - bash version: 3.00.15-(1) release (x86_64-redhat-linux-gnu)


share|improve this question
up vote 2 down vote accepted

An interpreted script can not have the interpreter in turn be another script, so the kernel exec*() fails with ENOEXEC.

At this point, POSIX requires that the shell interpret the script itself. SUSv3, "Command Search and Execution", 1.d.i.b second paragraph.

But zsh is not a POSIX shell. Instead, zsh looks at the #! line and tries to run that itself, passing it the original script as an argument. Which is what has happened here -- you didn't succeed in using ax as an interpreter for tst, handling the content of tst; you just passed tst as a parameter to ax.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.