bash での空っぽのコードブロック

| No Comments | No TrackBacks

bash では、ブロック中になにも有意なステートメントが存在しない if 節はだめらしい。
何もしない、なんていう不毛を許さない bash のパーサ。

[dxy@kit tmp]$ cat empty
#!/bin/sh

if [ $WHATEVER ]; then
fi

[dxy@kit tmp]$ ./empty
./empty: line 4: syntax error near unexpected token `fi'
./empty: line 4: `fi'
[dxy@kit tmp]$ vi empty
[dxy@kit tmp]$ cat empty
#!/bin/sh

if [ $WHATEVER ]; then
# comment doesn't help
fi

[dxy@kit tmp]$ ./empty
./empty: line 5: syntax error near unexpected token `fi'
./empty: line 5: `fi'
[dxy@kit tmp]$

[dxy@kit tmp]$ vi empty
[dxy@kit tmp]$ cat empty
#!/bin/sh

if [ $WHATEVER ]; then
# comment doesn't help
sleep 1
fi

[dxy@kit tmp]$
[dxy@kit tmp]$ ./empty
[dxy@kit tmp]$

kickstart の post-install script で、将来追加しようと思うブロックの
条件文だけを書いておいたら、それより後にある部分がごっそり実行されなくなりあせる。

No TrackBacks

TrackBack URL: http://www.grid5.net/mt/mt-trackback.cgi/267

Leave a comment

About this Entry

This page contains a single entry by dxy published on 2005年9月25日 15:56.

RHEL シリアルコンソール was the previous entry in this blog.

SSL 証明書 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 5.01