22.19 Shell Scripts Must be Readable and (Usually) ExecutableAlmost everyone knows that you need to make a program file executable - otherwise, UNIX won't execute it. Well, that's true for directly executable binary files like C and Pascal programs, but it's not quite true for interpreted programs like shell scripts. The UNIX kernel can read an executable binary directly - if there's execute permission, the kernel is happy; it doesn't need read permission. But a shell script has to be read by a user's UNIX program (a shell). To read a file, any UNIX program has to have read permission. So, shell scripts must be readable. Shell scripts don't need execute permission if you start the shell and give it the script file to read: % The execute permission is a signal to the kernel that it can try to execute the file when you type only the filename: % So shell scripts don't need to be executable - it's just handy. - |
|