2

Linux only supports one argument in a shebang line:

This:

#!/bin/sh
cat > pr_args <<'EOF'
#!/bin/sh -e
printf "'%s'\n" "$@"
EOF

cat > shebang <<'EOF'
#!pr_args a b c
EOF

chmod +x pr_args shebang

./shebang A B C


rm shebang pr_args

prints

'a b c'
'./shebang'
'A'
'B'
'C'

Are there any Unices where I'll get

'a'
'b'
'c'
'./shebang'
'A'
'B'
'C'

? What does Mac OS X do?

2

To take a look in all the detail of the shebang mechanism use the Mascheck page

In particular, the item about "Splitting arguments" and the table below to see the details for many different systems.

Also take a look at: "interpreter as #! script" to understand that not all systems allow one shebang to call some other shebang script.

If you need/require more detail, just ask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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