SUZUKI Yasuhiro wrote:
> スクリプトファイルをコマンドラインなどで実行する際に、
> まず初めに処理するのは、相変わらずシェルではないでしょうか?
> # execve()で、スクリプトファイルを直接実行
> # 可能であるとは知りませんでしたが。
十分な試験環境がないので、
手許の FC3 という以外の条件がはっきりしない環境での試行ですが、
[kusune@station ~]$ cat ./test.cat
#!/bin/cat -nE
test file.
[kusune@station ~]$ ./test.cat -b
1 #!/bin/cat -nE$
$
2 test file.$
[kusune@station ~]$ ./test.cat
1 #!/bin/cat -nE$
2 $
3 test file.$
[kusune@station ~]$ strace bash -c './test.cat -b' 2>&1 >/dev/null | grep execv
execve("/bin/bash", ["bash", "-c", "./test.cat -b"], [/* 25 vars */]) = 0
execve("./test.cat", ["./test.cat", "-b"], [/* 25 vars */]) = 0
[kusune@station ~]$
となり、bash が解釈してる形跡はないようにみえますね。
以下にひととおりつけておきます。
strace の出力も確認しましたけど長いのでやめておきますね。
気になる方はご自分の環境でもお試し下さい。
# 不要な試行の結果を削除したりしたので編集ミスがあるかも。
--
Takeshi Kusune <kusune@xxxxxxxxxxxxxx>
[kusune@station ~]$ echo $BASH_VERSION
3.00.14(1)-release
[kusune@station ~]$ uname -a
Linux station.east.group.gr.jp 2.6.11-1.35_FC3 #1 Mon Jun 13 00:52:18 EDT 2005 i586 i586 i386 GNU/Linux
[kusune@station ~]$ cat ./test.cat
#!/bin/cat -nE
test file.
[kusune@station ~]$ ./test.cat
1 #!/bin/cat -nE$
2 $
3 test file.$
[kusune@station ~]$ ./test.cat -b
1 #!/bin/cat -nE$
$
2 test file.$
[kusune@station ~]$ strace bash -c './test.cat -b' 2>&1 >/dev/null | grep execv
execve("/bin/bash", ["bash", "-c", "./test.cat -b"], [/* 25 vars */]) = 0
execve("./test.cat", ["./test.cat", "-b"], [/* 25 vars */]) = 0
[kusune@station ~]$ cat ./test2.cat
#!/bin/cat -n -E
test file.
[kusune@station ~]$ ./test2.cat
/bin/cat: invalid option --
Try `/bin/cat --help' for more information.
[kusune@station ~]$ ./test2.cat -b
/bin/cat: invalid option --
Try `/bin/cat --help' for more information.
[kusune@station ~]$ strace bash -c './test2.cat -b' 2>&1 >/dev/null | grep execv
execve("/bin/bash", ["bash", "-c", "./test2.cat -b"], [/* 25 vars */]) = 0
execve("./test2.cat", ["./test2.cat", "-b"], [/* 25 vars */]) = 0
[kusune@station ~]$
References:
- [linux-users:106104] Re: #!で始まるスクリプトKazuhiro NISHIYAMA
- [linux-users:106105] Re: #!で始まるスクリプトTakashi SHIRAI
- [linux-users:106106] Re: #!で始まるスクリプトSUZUKI Yasuhiro
- Prev by Subject: [linux-users:106106] Re: #!で始まるスクリプト
- Next by Subject: [linux-users:106108] Re: #!で始まるスクリプト
- Previous by thread: [linux-users:106106] Re: #!で始まるスクリプト
- Next by thread: [linux-users:106108] Re: #!で始まるスクリプト
- Indexes:[Main][Thread]