私はこのbashスクリプトを見つけました(これは機能します)。このスクリプトは重要な役割を果たします。スクリプトの全体的なコード品質は良好です。次の構造に何か意味があるのだろうか?
if [ "${G_FILE}" != "" ] && [ -f "${G_FILE}" ] && [ -r "${G_FILE}" ]; then
....
マニュアルには次のように書かれています。
[ -f FILE ] True if FILE exists and is a regular file.
[ -r FILE ] True if FILE exists and is readable.
[ STRING1 != STRING2 ] True if the strings are not equal.
私の考え:
[ -n "${G_FILE}" ]
または[ "${G_FILE}" ]
の代わりになり[ "${G_FILE}" != "" ]
ます。- 同じことをするだけ
[ -r "${G_FILE}" ]
です。
私は正しいですか?