0

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

#!/usr/bin/env zsh

print "Params: $*"
cat $*

And another one 'tst':

#! /home/me/ax
A
B
C

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
A
B
C

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)

Thanks

Benoit
  • 3,549
  • 1
  • 19
  • 17
yogsototh
  • 103
  • 4

1 Answers1

2

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.

Phil P
  • 3,080
  • 1
  • 16
  • 19